Domain Mapping to Github

A Records vs. CNAME Records

When you are mapping a domain on GitHub pages (or on any site really) an important concept you want to try and wrap your head around is the difference between A Records and CNAME Records. I’m getting closer to full comprehension, but a little help never hurts so I took the following definition from DNS Simple:

The A record points a name to a specific IP. For example, if you want blog.dnsimple.com to point to the server 185.31.17.133 you will configure

blog.dnsimple.com. A 185.31.17.133

The CNAME record points a name to another name, instead of an IP. The CNAME source represents an alias for the target name and inherits its entire resolution chain. Let’s take our blog as example.

blog.dnsimple.com. CNAME aetrion.github.io.

To summarize, an A record points a name to an IP. CNAME record can point a name to another CNAME…

It’s good practice to point domains using CNAME Records when possible because IP addresses can change, and when they do an A Record will break because it is hardcoded. You might think of CNAME Records as relative hostnames, hence the IP address can change regularly but the mapped domain will not break.

One issue is that root domains (sometimes called “zone apex” or “naked domain”) have to be setup as an A Record, not a CNAME. This means that with most DNS providers you can setup a subdomain CNAME (blog.jimgroom.me) to point to a service like GitHub, but you cannot setup your root domain (jimgroom.me) as a CNAME. That root domain would have to be an A Record. Make sense? Good.

Mapping your Domain on GitHub

As you might have guessed from the above definitions, there are two methods for mapping a custom domain on GitHub: CNAME and A Records. You can get a good overview of how Custom Domains work on GitHub here. Mapping a subdomain using a CNAME is recommended so the domain doesn’t break if the server IP changes, which may very well happen. That said, we understand sometimes you just need that root domain mapped, so an A Record is nice and will suffice.

Mapping your Root Domain with A Records

For this example I’ll be mapping the root domain jimgroom.me onto a Github page. In terms of getting your Github pages setup for this see GitHub’s “Setting Up a Custom Domain with GitHub Pages.”

First you need to find the Advanced Zone Editor under the Domains section in CPanel.

Advanced Zone Editor

After that you need to choose the root domain you will be mapping. In the example screenshot below you’ll see I have several, but you may only have one which would be the default.

Root Domain

Once you select the domain you need to create two A Records for it using the below screenshot as a template, through the Name will obviously be different depending on the root domain you are mapping. The two a Records will point to the following IP addresses on GitHub: 192.30.252.153 and 192.30.252.154. You need to create a separate A Record for each of these IPs.

A Records

Once you have created both A Records in the Advanced DNS Zone Editor you should be all set. GitHub has their own documentation with “Tips for Configuring an A Record with Your DNS Provider” that might also be useful. If you are having any issue see GitHub’s “My Custom Domain Isn’t Working” or contact us.

Mapping your Subdomain with CNAME Records

For this example I’ll be mapping the subdomain blog.jimgroom.com onto a GitHub Pages Repository using a CNAME Record. Head to Advanced DNS Settings.

Zone Editor

Once there, select the domain you will be mapping to if you have more than one.

Mapping

Now you name to add a CNAME Record with the subdomain you are mapping in the Name field and the URL of your GitHub account in the CNAME field.

CNAME

After that you should be set. I found even if your repository is jimgroom.github.io/blog like mine is in this instance, you only need jimgroom.githib.io in the CNAME field.

If you need more help, feel free to contact Reclaim Hosting support.