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.
- (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:
- Create AAAA records for apex domain (IPv6), to direct IPv6 traffic by pointing the apex domain tot GitHub Pages IP addresses:
- 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 184.108.40.206 venegas.me. 0 IN A 220.127.116.11 venegas.me. 0 IN A 18.104.22.168 venegas.me. 0 IN A 22.214.171.124
- Check AAAA Records with dig by running the same command above, except replace
- Verify the CNAME against the www entry with
dig. Notice how
wwwis included in this check.
dig www.venegas.me +nostats +nocomments +nocmd
digshould 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 126.96.36.199 venegasme.github.io. 0 IN A 188.8.131.52 venegasme.github.io. 0 IN A 184.108.40.206 venegasme.github.io. 0 IN A 220.127.116.11
- 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.tldto 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
- Verify your domain to enable the “verified” badage in GitHub.