-
Notifications
You must be signed in to change notification settings - Fork 10
Using a Custom Domain
After signing into your GoDaddy.com account, choose the Manage Domains option from your account page or the account dropdown at the top of the home page.
On the My Domains page, click the ellipsis that follows your domain name you want to use.
From the dropdown menu that appears, choose Manage DNS
If your domain is not currently hosted on another server, you will see that there is what's known as an A record for your domain with a value of Parked. A Records are simply a type of DNS record used to point a domain or subdomain to an IP address. The value of Parked indicates that the domain is not currently in use.
We need to edit this A record by replacing the value of Parked with the IP address for GitHub's servers. To do this, click on the pencil icon on the far right of the record entry in the list and replace the word parked in the Points to field with 192.30.252.153. Click Save to save your changes.
Next, we need to create another A record because GitHub has two servers that manage all of the traffic to it. Click the ADD button at the bottom right of the list of records for your domain and choose A from the Type field select list. In the Host field enter @. The @ symbol means 'the current origin', or more simply put, for your domain. In the Points to field enter the second server address of 192.30.252.154. Now, choose the Custom option from the TTL select field. TTL stands for Time to Live and it tells the nameservers that they should only cache this IP address for a specific period of time. If the address is changed by you in the future because you move your site to a different server, you would want that change to be immediate, so we'll use the value of 600 in the Seconds field.
The last thing we're going to do here is create a CNAME record. A CNAME record is a type of DNS record that maps an alias name to actual (or canonical, hence the C in CNAME) domain name. So, once again click the ADD button at the bottom right of the list of records for your domain, but choose CNAME from the Type field select list this time. With this record we are going to make sure that if someone types www.your-custom-domain.com that the traffic is also routed to your site. Therefore, in the Host field, enter www and then in the Points to field, enter your GitHub pages url. For the purposes of the CNAME record, you can leave the default value of 1 Hour in the TTL field.
Almost done... now you can go to your GitHub repo for your GitHub Pages site. It will be at: github.com/yourusername/yourusername.github.io. On the Code tab, click the button that reads Create new file.
Name your new file: CNAME. Make sure it is in all capital letters and has no additional punctuation or characters in the name and add the name of your domain on the first line
Click the Commit button at the bottom of the page. 🎉
It may take several minutes for the updates to take effect. Test out your new custom domain!