Custom domain with GitHub Pages and Namecheap

So you’ve setup you own personal GitHub Pages site and bought a custom domain from Namecheap, now what? In this blog post I’ll show you how to configure your GitHub Pages site to use your new custom domain in less than 5 minutes.

Namecheap

First we will configure the DNS settings for your custom domain through Namecheap’s domain control panel.

  1. Navigate to your domian list and click Manage on the domain you wish to configure.
    Screenshot of the Namecheap domain list
  2. Click on the Advanced DNS tab and Scroll down to Host Records section.
    Screenshot of the Namecheap DNS control panel
  3. Update the CNAME record by setting the value to your GitHub Pages repository, in my case it was ryanmichaeljames.github.io., and leave TTL as Automatic.
    Screenshot of the CNAME record
  4. Next we’ll add a few A records with the GitHub’s IP addresses and set their TTL to Automatic.
    185.199.108.153
    185.199.109.153
    185.199.110.153
    185.199.111.153
    

    Screenshot of the A records

Next we will configure your GitHub Pages site.

GitHub

Finally lets configure your GitHub Pages site to use your custom domian and enable SSL.

  1. Navigate to your GitHub Pages site’s repository and click on the Settings tab and scroll down to the GitHub Pages section.
    Screenshot of the GitHub settings tab.
  2. Under Custom domain enter your new domian name and click Save.
    Screenshot of the GitHub Pages custom domain field A file named CNAME has been added to your repository.
    Screenshot of CNAME file
  3. Finally check Enforce HTTPS to enable SSL for your site.
    Screenshot of the GitHub Pages enforce HTTPs field

Don’t forget to include www in your custom domain name. This will prevent the ERR_CERT_COMMON_NAME_INVALID error when you browse to www.<domain>.<tld>.

Easy as!

Sorted! You should now have both your GitHub Pages site and your DNS setup. All you need to do is test that it works.

It may take up to 24 hours for your DNS configuration to propagate and for you to successfully browse to your site using your custom domian. For me, it took about 30 minutes.

All views expressed in my blog are my own and do not represent the opinions of any entity whatsover with which i have been, am now, or will be affiliated.