How to Connect a Domain to GitHub Pages (CNAME Steps)
Custom domain on GitHub Pages with CNAME file, DNS records and HTTPS enforcement.
By DigitalNepal · Updated 2026-10-04
GitHub Pages hosts static sites free with custom domains. The CNAME file plus two DNS records do the job.
Steps
1Add CNAME file
In the repo's publishing root, create a file named CNAME containing only your domain, then deploy.
2Add DNS records
At your registrar: apex A records to GitHub's IPs (check current docs) or CNAME www to username.github.io.
3Set custom domain in repo
Repo Settings > Pages > Custom domain: enter it and save. Wait for DNS check.
4Enforce HTTPS
Tick Enforce HTTPS once available. Mixed-content warnings vanish.
Good to know: DNS changes take minutes to hours. Verify with the DNS Checker tool before assuming failure.
FAQ
Apex or www?
Use both: apex A records plus www CNAME, with www redirecting consistently.
Was this page helpful?
Related tools
Related guides
How to Connect a Domain to Vercel (Nameservers or Records)
Add domain in Vercel, verify with DNS, and get automatic HTTPS.
How to Buy a Domain in Nepal (Registrar, Payment & Setup)
Choose a registrar, pick the right TLD, pay from Nepal, and point DNS correctly.
How to Connect a Domain to Render (Custom Domain Steps)
Point domains to Render web services with DNS verification and auto TLS.
How to Connect Cloudflare to a Domain (Nameserver Method)
Move DNS to Cloudflare for free CDN, firewall and HTTPS in 4 steps.