Using GitHub Pages with a custom domain: Namecheap Edition
As often happens, I found the official documentation and forum answers to be "close, but no cigar", and so had to experiment a little to get things working.
The main problem for me was a lack of concrete configuration examples. That's not entirely GitHub's fault: having migrated from Google Domains to Namecheap in the middle of this project, I was once again reminded of how many different ways there are to do things in the name service universe .
Although you'd think the simplest setup would be to merely configure for the subdomain case (https://www.example.com), in my experience using the apex domain (https://example.com) instead resulted in fewer complications.
So here's my recipe for using a custom domain with GitHub pages where Namecheap is the DNS provider:
- Create A records for apex domain in Namecheap Advanced DNS panel for the domain(in this example, the fictional "example.com"):
|A Record||@||220.127.116.11||30 minutes|
|A Record||@||18.104.22.168||30 minutes|
|A Record||@||22.214.171.124||30 minutes|
|A Record||@||126.96.36.199||30 minutes|
|CNAME Record||www||youracctname.github.io||30 minutes|
- Wait an hour, then test if DNS is set up properly:
me@myhost:~$ dig +noall +answer +nocmd example.com example.com. 1800 IN A 188.8.131.52 example.com. 1800 IN A 184.108.40.206 example.com. 1800 IN A 220.127.116.11 example.com. 1800 IN A 18.104.22.168
me@myhost:~$ dig +noall +answer +nocmd www.example.com www.example.com. 1800 IN CNAME youracctname.github.io. youracctname.github.io. 3600 IN A 22.214.171.124 youracctname.github.io. 3600 IN A 126.96.36.199 youracctname.github.io. 3600 IN A 188.8.131.52 youracctname.github.io. 3600 IN A 184.108.40.206
In the GitHub repo config for Pages (Settings... Pages), enter your apex domain, "example.com" (not "www.example.com") in the "Custom Domain" box.
Wait for GitHub to generate ahd install the SSL certificate for that apex domain (at least an hour).
I highly recommend not changing domain registrars and DNS providers in the middle of all that.
 The other problem is how damned long it takes for things to propagate across global DNS, especially when starting with TTLs of an hour (the trick is to try reducing your TTL before making any other changes, going from an hour to fifteen minutes can make a huge difference in blood pressure readings). Even with shorter TTLs, you need to anticipate upwards of an hour delay between changes. So chill. Read a book. Talk to the dog.
"Configuring a custom domain for your GitHub Pages site". GitHub Docs, https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site, Retrieved 9 September 2021.
"How do I link my domain to GitHub Pages". Namecheap Knowledgebase, https://www.namecheap.com/support/knowledgebase/article.aspx/9645/2208/how-do-i-link-my-domain-to-github-pages/, Retrieved 10 September 2021.