After some (mis)adventures, I finally got my custom domain name directed to my GitHub Pages site successfully. Here is what worked, in case someone else has the same problem.
I first tried clearing all of my DNS records and adding only the ones I thought I needed. Don’t do that. I got a “Nameserver is not authoritative” error, and didn’t know how to get back to the defaults.
GitHub Pages Configuration
To use GitHub Pages, all you have to do is create a public repo and turn on GitHub Pages at the bottom of ‘Settings’. However, I highly recommend using the default GitHub Pages repo name (your-user-name.github.io) so that the hosted website is just https://your-user-name.github.io without a trailing folder name. This means that root-relative-urls (/assets/css/styles.css) will work consistently locally, hosted at GitHub, and hosted at CloudFlare Pages.
You choose the branch to publish in the GitHub repo Settings page. I’m choosing a ‘release’ branch, so that I can work directly in main and push frequently to back up but not publish half-finished work.
Also, don’t turn on ‘Enforce HTTPS’ initially - get your domain working correctly first.
See Managing a custom domain for your GitHub Pages site - GitHub Docs for the official documentation. It was good, but didn’t fully tell me which DNS records I needed to get things working.
DNS Record Configuration
After my misadventure, Domain.com Support was able to restore the defaults for me.
After that, here are the changes that worked:
- Record the default types, names, and values, in case you need to replace them.
- Remove the ‘@’ and ‘*’ A records and the ‘_acme-challenge’ CNAME record.
- Add ‘@’ A records for each of the GitHub Pages IP addresses.
- Add ‘www’ A records for each of the GitHub Pages IP addresses.
Then:
- Wait (about two hours, for me).
- Verify via LeafDNS.com
- Flush your PC DNS cache (on Windows, “ipconfig /flushdns”)
- Verify your domain resolves to your website in the browser.
- In your GitHub repo Settings, turn on “Enforce HTTPS”
… and then my site finally worked!