What you are actually connecting
GitHub Pages hosts your static site's files for free on GitHub's infrastructure, but it does not sell or manage domain names. You register your domain separately (with any registrar) and then add DNS records that tell the internet "this domain's content lives on GitHub Pages." The whole process is just DNS configuration — no code changes are needed on the GitHub side beyond one settings field.
Two scenarios: apex domain vs www subdomain
An apex (or root) domain is the bare name, like yoursite.com. A www subdomain is www.yoursite.com. GitHub Pages needs slightly different DNS records for each, because apex domains cannot use a CNAME record at the DNS level — only A (or ALIAS/ANAME) records are allowed at the root.
Step-by-step: connecting an apex domain (yoursite.com)
- In your DNS management panel, add four A records for the @ / root host, pointing to GitHub Pages' IP addresses: 185.199.108.153, 185.199.109.153, 185.199.110.153, and 185.199.111.153
- In your GitHub repository, go to Settings → Pages → Custom domain, and enter your apex domain (e.g. yoursite.com)
- GitHub will create a CNAME file in your repository automatically confirming the custom domain
- Wait for DNS propagation (usually under an hour, occasionally longer) and enable "Enforce HTTPS" once GitHub finishes issuing a certificate for your domain
Step-by-step: connecting a www subdomain
- Add a CNAME record for the host "www" pointing to yourusername.github.io (replace with your actual GitHub username or organization name)
- Enter www.yoursite.com in the same GitHub Pages custom domain field
- Most people configure both the apex and www, then let GitHub Pages redirect one to the other automatically once both are verified
Common issues and how to fix them
If your domain shows a "DNS check unsuccessful" message in GitHub's settings, the most likely cause is that the A records or CNAME have not finished propagating yet — this can occasionally take a few hours. If it persists, double-check you added exactly the four documented GitHub Pages IP addresses (not your hosting provider's IP) and that there is no conflicting A or CNAME record left over at the same host from a previous setup.
GitHub's official documentation is the definitive source for the current IP addresses, since these can occasionally change — always cross-check before relying on any third-party guide, including this one.