Skip to content
DigitalNepal.tech

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

A

GitHub Pages hosts static sites free with custom domains. The CNAME file plus two DNS records do the job.

Steps

  1. 1Add CNAME file

    In the repo's publishing root, create a file named CNAME containing only your domain, then deploy.

  2. 2Add DNS records

    At your registrar: apex A records to GitHub's IPs (check current docs) or CNAME www to username.github.io.

  3. 3Set custom domain in repo

    Repo Settings > Pages > Custom domain: enter it and save. Wait for DNS check.

  4. 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.

Share:FacebookXWhatsApp

Was this page helpful?

Related tools

Related guides

← Back to How-To Guides