Setting up custom domain with Github Pages

Let’s take the example of my domain itself abhipandey.com that I want to serve from abhi1010.github.io. We will need to do it in two steps:

Change CNAME

If we want to tell github about the domain name, it is rather simple: create a CNAME file with the content being the name of the domain itself Do note here that the default redirect of your domain will be the value in your CNAME file.

Here’s my CNAME file content:

abhipandey.com

You don’t really need www. If you do put www.abhipandey.com github will figure out and redirect properly. The difference is abhipandey.com is a top-level domain (TLD), while www.abhipandey.com is a subdomain.

Essentially:

If your CNAME file contains abhipandey.com, then www.abhipandey.com will redirect to abhipandey.com.

If your CNAME file contains www.abhipandey.com, then abhipandey.com will redirect to www.abhipandey.com.

Creating A Record

Setting up A record

Setting up A record

Next is to go to Amazon Route 53 console, and create an A record with the following IPs:

192.30.252.153
192.30.252.154

Setup subdomain

Setting up subdomain

Setting up subdomain

If you configure both an apex domain (e.g. abhipandey.com) and a matching www subdomain (e.g. www.abhipandey.com), GitHub’s servers will automatically create redirects between the two.

You can also also look up GitHub Tips for configuring an A record with your DNS provider.

comments powered by Disqus