Configure Custom Domain Name for GitHub Pages using NameCheap

So you’ve got a fancy new blog, hosted on GitHub Pages, and you’re ready to show it off to the world? You can access it via username.github.io, but that’s still not good enough. Well, lucky for you, it’s pretty easy.

Note: If you don’t already have a good web host, I highly recommend BlueHost. I’ve partnered with them to get you an introductory rate of $3.95/month.

As I was trying to set up my blog with a custom domain, I was also attempting to use CloudFlare as my CDN before I even got my custom domain name up and running, and so that definitely messed me up trying to get everything working. Eventually, I ultimately just ditched CloudFlare altogether (there may be a blog post coming about that. I don’t know) because a static site running on GitHub pages is quick enough.

I eventually got it all figured out, and I decided I’d share how to do it. I’m using NameCheap as my domain registrar, but you should be able to use these steps for whoever you want to choose (GoDaddy, HostGator, whoever).

First things first, you’ll want to upload a file called CNAME (without any extensions) to the root directory of your GitHub Pages repo. Inside of it, you’ll want to put the url of your custom domain (i.e. “www.yoursitehere.com”). In my case, obviously, my CNAME contains “www.brycematheson.io”.

Custom Domain Name

Once you’ve done that, head on over to NameCheap.com. Under “Account”, select “Domain List”. Next to the domain that you want to use as your custom domain name for your site/blog, click “Manage”. Then, select “Advanced DNS” from the top menu and you should see something like this:

Custom Domain Name

You’ll want to create four entries:

  • The first entry will be an “A Record” type, with an “@” as your host, and an IP Address of 192.30.252.153.
  • The second entry will be nearly identical to the first entry, except have an IP Address of 192.30.252.154.
  • The third entry will be a type of “CNAME Record”, with a host of “www”, and in the values column, you’ll want to put the current path to your GitHub Pages site (i.e. username.github.io).
  • And the fourth will be similar to the third entry, except in the value column, you’ll want to enter the name of your custom domain.

If all else fails, just refer to the picture above as a guide. Wait about 20-30 minutes for your domain to propagate, and you should be in business.

One last thing to mention: Under my third entry, in the “TTL column”, I have it set to 20 minutes. Why? I don’t know. I’ve been playing with it, but haven’t noticed much of a change. I’ll report back if I figure out anything cool.

Leave a Reply

Your email address will not be published.