GitHub Pages - Setup www and apex for Custom Domain

GitHub Pages - Setup www and apex for Custom Domain

Add a custom domain name with www and apex (sub-domain-less)DNS entries for a GitHub Pages site. GitHub pages are static content hosted on *.github.io domain.

Why GitHub Pages? It's free hosting, the deployments are as simply as git push, SSL/TLS certificates are includee, and apex domain redirects (from www to apex) are included.

Instructions

  1. (optional) Create an GitHub Organization so Projects can be more easily shared with others. Useful when multiple people require management and publishing rights.
  2. Add a GitHub Project named user.github.io or organization.github.io to hold the site content.
  3. Setup DNS at your DNS Provider so traffic is redirected to GitHub Pages from your domain.
    1. Visit your DNS provider, not GitHub
    2. Create A records for apex domain to direct IPv4 traffic by pointing the apex domain tot GitHub Pages IP addresses:
      • 185.199.108.153
      • 185.199.109.153
      • 185.199.110.153
      • 185.199.111.153
    3. Create AAAA records for apex domain (IPv6), to direct IPv6 traffic by pointing the apex domain tot GitHub Pages IP addresses:
      • 2606:50c0:8000::153
      • 2606:50c0:8001::153
      • 2606:50c0:8002::153
      • 2606:50c0:8003::153
    4. Create a CNAME record for WWW to direct traffic from www.<apexdomain> to GitHub Pages.
    5. Let DNS Propogate by waiting 15 minutes, then checking DNS with dig, a command-line tool.
      1. Verify A Records with dig
        dig venegas.me +noall +answer -t A
        dig should find the four A records created above.
        venegas.me.             0       IN      A       185.199.108.153
        venegas.me.             0       IN      A       185.199.109.153
        venegas.me.             0       IN      A       185.199.110.153
        venegas.me.             0       IN      A       185.199.111.153
      2. Check AAAA Records with dig by running the same command above, except replace A with AAAA
      3. Verify the CNAME against the www entry with dig. Notice how www is included in this check.
        dig www.venegas.me +nostats +nocomments +nocmd
        dig should locate a redirect from the CNAME to *.github.io IP Addresses.
        www.venegas.me.         0       IN      CNAME   venegasme.github.io.
        venegasme.github.io.    0       IN      A       185.199.108.153
        venegasme.github.io.    0       IN      A       185.199.109.153
        venegasme.github.io.    0       IN      A       185.199.110.153
        venegasme.github.io.    0       IN      A       185.199.111.153
    6. Setup the Custom Domain in the GitHub Project to tell GitHub to start serving traffic. On GitHub, open the *.github.io project and navigate to Settings -> Pages -> Custom Domain. Add yourdomain.tld to add the apex entry, hit save, and fix any errors detected by GitHub.
    7. Congradulations! Your custom domain should be serving traffic from http://venegas.me, https://venegas.me, ,http://www.venegas.me>, and even https://www.venegas.me

Next Steps