Faster loading for GitHub pages using custom root domains

Published on


I use a GitHub page to host my personal landing page (https://hadi.io) and Gandi for domain and DNS services. After setting up my custom domain using the GitHub instructions here: https://help.github.com/articles/tips-for-configuring-an-a-record-with-your-dns-provider I noticed that the page was taking ages to load... and sometimes not loading at all. I always blamed my network and didn't think too much of it, until today when I tweeted about it:


I got pointed to this page, which explains GitHub's move to use a CDN: https://github.com/blog/1715-faster-more-awesome-github-pages - it seems that the best way to configure your DNS is to use an ALIAS record that points directly to username.github.io. Since Gandi don't support this (although it is on their wish-list), I moved my DNS to CloudFlare.

Now although CloudFlare still don't allow you to use an ALIAS record to point your custom apex domain to github, they do allow you to have a CNAME record on the root domain (see CNAME Flattening). So I did that, it was free and super simple:

  • Add your website, CloudFlare will then fetch your DNS configuration
  • I removed my two A records pointing to "192.30.252.153" and "192.30.252.153"
  • Added a CNAME (using the @ symbol to denote my root domain) that points to hadimichael.github.io
  • I then updated my DNS Provider settings on Gandi, and that was it!

Other references that were useful to me: