How to connect your domain to Github Pages

Want to link your domain to Github Pages? We can do that!

Configure Github Pages

First up, you need to prepare Github Pages for browser requests for your custom domain. Here's their guide that shows how to do it:

"Adding or removing a custom domain for your GitHub Pages site"

Setting up "www"

According to the Github article "Setting up a www subdomain," to configure your domain for requests for www.yourdomain.example, you must configure a CNAME record for "www." Here's how:

Log in. You should arrive at the Domain Management screen. If you're already logged in, click your username in the top-right corner and select Domain Management.
Click the black "gear" icon to the far right of your domain and click "DNS Records."
Add a new CNAME record:

Change Type to "CNAME - Canonical name record."
Under Host type: www
Under Answer type:   …where  YOUR-GITHUB-USERNAME is your actual username
Click Add.

Setting up your apex domain A records

Great, but what if someone visits your site but leaves out the "www?" According to the Github article "Setting up an apex domain," you must add two a A records to address that scenario. Here's how:

On the Manage DNS Records screen, scroll down and locate the one or more A records that are currently pointing at the wrong web server. Click the trash can icons to the right of the bad records to remove them.
Scroll up to the top of the Manage DNS Records screen to add the correct A records. 
For the first record, make sure that  Type is set to "A - Address record" the Host is left blank and the Answer is   …then hit Add. 
For the second record, make sure that  Type is set to "A - Address record" the Host is left blank and the Answer is      …then click Add.
Click the X icon in the top right of the popup box to close "Manage DNS Records"

That's it! After five minutes or less, browser requests to your domain should start resolving to Github Pages.