Development · 5 min read

How to add a custom domain to GitHub Pages

GitHub Pages ships with a github.io subdomain out of the box, which is fine for a personal project but reads as a draft the moment someone else sees it. Pointing a real domain at it takes about ten minutes of DNS work and a single field in the repo settings.

Prerequisites

Before you start, you’ll need:

Add your custom domain in GitHub

In your repository, go to Settings → Pages and add your domain under the custom domain field. GitHub will start a DNS check in the background. It’ll fail at first, which is expected, because the DNS records don’t exist yet.

Add A records and a CNAME at your DNS provider

GitHub Pages uses four static IPs for apex domains. Add an A record for each one on your root domain (@):

185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153

Then add a CNAME record for www that points to <username>.github.io (replacing <username> with your GitHub username, or the org name if the repo is owned by an org).

Always cross-check the GitHub Pages custom domain docs for the current IPs. GitHub has rotated them in the past.

Registrar-specific steps

The DNS records above are the same everywhere. Only the UI changes between registrars. Here’s where to find DNS settings at a few common ones.

GoDaddy

Namecheap

HostGator

Wait for DNS to propagate

DNS changes take anywhere from a few minutes to 24 hours to propagate. You can track it with DNSChecker, which shows how the records resolve from different locations around the world.

Once it’s propagated, GitHub’s DNS check will turn green and the Enforce HTTPS checkbox will become available. Turn it on. Your domain is live.

Share:

Your Friday WooCommerce briefing

What changed this week, what broke, and what you should try. Plugin news, store fixes, and opinions. No fluff, no affiliate spam.

Sent every Friday. Unsubscribe in one click.

This blog is independent and ad-free. If a post saved you time or taught you something new, a coffee goes a long way.

Have thoughts, questions, or a different take? I'd love to hear from you.

Powered by Giscus · Sign in with GitHub to comment. · Privacy policy