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
- (optional) Create an GitHub Organization so Projects can be more easily shared with others. Useful when multiple people require management and publishing rights.
- Add a GitHub Project named user.github.io or organization.github.io to hold the site content.
- Setup DNS at your DNS Provider so traffic is redirected to GitHub Pages from your domain.
- Visit your DNS provider, not GitHub
- 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
- 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
- Create a CNAME record for WWW to direct traffic from www.<apexdomain> to GitHub Pages.
- Let DNS Propogate by waiting 15 minutes, then checking DNS with
dig
, a command-line tool.- Verify A Records with digdig should find the four A records created above.
dig venegas.me +noall +answer -t A
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
- Check AAAA Records with dig by running the same command above, except replace
A
withAAAA
- Verify the CNAME against the www entry with
dig
. Notice howwww
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
- Verify A Records with dig
- 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. - 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
- Verify your domain to enable the "verified" badage in GitHub.