GitHub Pages Custom Domain: DNS, CNAME and HTTPS Setup
How to set a GitHub Pages custom domain: the DNS records for apex and www, what the CNAME file does, domain verification, and turning on HTTPS.
Short answer: In your repository, go to Settings > Pages, type your domain under Custom domain, and save. Then, at your DNS provider, point www to <username>.github.io with a CNAME record, and point the bare domain (example.com) to GitHub with four A records. When GitHub finishes issuing the certificate, tick Enforce HTTPS. The whole thing is a repo setting plus a few DNS records. Most delays come from DNS propagation, which GitHub says can take up to 24 hours.
Everything below was checked against GitHub's own documentation in November 2026. DNS values are the part most likely to change, so confirm them on the GitHub Pages custom domain docs before you paste.
Pick your domain type first
| You want visitors to land on | Set as custom domain | DNS records needed | Notes |
|---|---|---|---|
www.example.com | www.example.com | CNAME on www to <username>.github.io, plus A records on the apex | GitHub's recommended setup. example.com redirects to www. |
example.com | example.com | A records on the apex (or one ALIAS/ANAME), plus a CNAME on www | www.example.com redirects to the apex. |
blog.example.com | blog.example.com | CNAME on blog to <username>.github.io | No apex records needed. |
GitHub's docs say www subdomains are the most stable choice because they are not affected by changes to GitHub's server IP addresses. If you do not have a strong reason to use the bare domain, pick www. If you are still shopping for a registrar, our domain registrar comparison covers the options, and what a domain costs explains renewal pricing.
Step-by-step: connect the domain
- Add the domain in GitHub. Open your repository, click Settings, then Pages (under "Code, planning, and automation"). If the Settings tab is hidden, look in the "More" dropdown. Type your domain in the Custom domain field and click Save.
- Check what GitHub did to your repo. If you publish from a branch, GitHub commits a
CNAMEfile to the root of that branch. If you publish from a custom GitHub Actions workflow, no CNAME file is created, and any existing one is ignored. - Remove default DNS records. If your DNS provider auto-created a parking or default record for the host you are about to use, delete it first.
- Create the DNS records at your DNS provider (see the next section).
- Wait for propagation. GitHub says up to 24 hours. You can check progress from a terminal with
dig www.example.com +noall +answer. - Enforce HTTPS once the option becomes available (see below).
Order matters less than you think
You can create DNS records before or after saving the domain in GitHub. The risk is leaving DNS pointing at GitHub Pages while the domain is not claimed by any repo. GitHub warns that configuring DNS without adding the domain to GitHub could let someone else host a site on one of your subdomains. Save the domain in GitHub first, then do DNS.
The DNS records
www or any subdomain: one CNAME
| Type | Host | Value |
|---|---|---|
| CNAME | www | <username>.github.io |
Use your username or organization name, without the repository name. GitHub specifically says not to point the CNAME at the unique *.pages.github.io address shown in your repository settings.
Apex domain: four A records (checked November 2026)
| Type | Host | Value |
|---|---|---|
| A | @ | 185.199.108.153 |
| A | @ | 185.199.109.153 |
| A | @ | 185.199.110.153 |
| A | @ | 185.199.111.153 |
Optional IPv6, if you want it, as AAAA records on @:
| Type | Host | Value |
|---|---|---|
| AAAA | @ | 2606:50c0:8000::153 |
| AAAA | @ | 2606:50c0:8001::153 |
| AAAA | @ | 2606:50c0:8002::153 |
| AAAA | @ | 2606:50c0:8003::153 |
GitHub recommends adding the A records even if you add AAAA records, because IPv6 adoption is still uneven. If your DNS provider supports ALIAS or ANAME records, you can use a single one pointing to <username>.github.io instead of the A and AAAA records.
Two mistakes to avoid:
- Extra records on the apex. GitHub says additional A, AAAA, ALIAS or ANAME records on
@, or a CNAME on www pointing elsewhere, may prevent the HTTPS certificate from being generated. - Pointing a subdomain at your apex. GitHub warns this causes problems enforcing HTTPS and may stop the subdomain from reaching your site at all. Point subdomains at
<username>.github.io.
Some providers use @ for the apex host and some want you to leave the field blank or type the full domain. That is a provider quirk, not a GitHub setting.
Turn on HTTPS
GitHub issues certificates for custom domains through Let's Encrypt. After DNS resolves correctly:
- Go back to Settings > Pages.
- Look for a check mark beside your domain, which means the DNS check passed.
- Tick Enforce HTTPS.
GitHub says the option can take up to 24 hours to become available. If it has not appeared several minutes after you saved, GitHub's suggested fix is to click Remove next to the custom domain, retype it and click Save again. The domain also has to be under 64 characters for a certificate to be created.
If the checkbox stays grayed out, work through this list:
- [ ] DNS for the host resolves to GitHub (
digshows the four IPs or your<username>.github.ioCNAME) - [ ] No extra A, AAAA, ALIAS or ANAME records on the apex
- [ ]
wwwCNAME points to<username>.github.io, not to the apex or a pages.github.io address - [ ] The domain in Settings > Pages matches exactly what you typed in DNS
- [ ] You removed and re-added the domain once
Verify the domain (strongly recommended)
Verification stops other GitHub accounts from claiming your domain if your Pages site is ever unlinked. GitHub lists domain takeovers as possible when you delete the repository, when your billing plan is downgraded, or after any change that unlinks the domain while it remains configured for GitHub Pages and is unverified.
- Open your profile settings (not the repo settings), then Pages in the sidebar.
- Click Add a domain, enter it and confirm.
- Create the TXT record GitHub shows you. The host will look like
_github-pages-challenge-USERNAME.example.com. - Confirm it is visible with
dig _github-pages-challenge-USERNAME.example.com +nostats +nocomments +nocmd TXT. - Back in GitHub, use the menu beside the domain, choose Continue verifying, then Verify.
GitHub says this may be immediate or take up to 24 hours. Leave the TXT record in place afterward. Also skip wildcard records like *.example.com: GitHub says they risk takeover even when the domain is verified.
Common problems
- 404 on the custom domain, site works at github.io. The domain was never saved in Settings > Pages, or DNS has not propagated. Check both.
- Domain keeps resetting after a deploy. If you publish from a branch, the
CNAMEfile in the source branch must contain your domain. A build that wipes the branch root, or a deploy that omits the file, can remove it. Switching to a custom Actions workflow makes the file unnecessary. - Apex works, www does not (or the reverse). Both hosts need records. Remember GitHub redirects the paired host only if its DNS points at GitHub Pages as well.
- Certificate never arrives. Run the checklist above, looking for stray records first.
If you would rather not manage DNS yourself
GitHub Pages is a good fit for static sites you already keep in a repository. If you mainly need a site online with your own domain, We.Inc's custom domains walk you through the same DNS step inside the builder, and the domain connection guide covers it for any provider. We.Inc's free plan lets you publish up to three sites from ready-made templates; the AI builder that drafts a site from a prompt starts on the Starter plan at $20 a month. You can sign up here.
Frequently asked questions
What IP addresses do I use for a GitHub Pages apex domain?
GitHub's docs (checked November 2026) list four A records for the apex host (@): 185.199.108.153, 185.199.109.153, 185.199.110.153 and 185.199.111.153. If you want IPv6 as well, add four AAAA records: 2606:50c0:8000::153, 2606:50c0:8001::153, 2606:50c0:8002::153 and 2606:50c0:8003::153. GitHub recommends keeping the A records alongside the AAAA records. Compare against the docs before you paste them, since GitHub can change these values.
Do I need a CNAME file in my repository?
Only if you publish from a branch. In that case, saving the custom domain in Settings > Pages commits a CNAME file to the root of the source branch for you. If you publish with a custom GitHub Actions workflow, GitHub says no CNAME file is created and any existing one is ignored and not required.
Why is the Enforce HTTPS checkbox grayed out?
GitHub says it can take up to 24 hours before the option is available after you add the domain. The certificate is issued automatically, so the usual causes of a stuck checkbox are DNS that has not propagated yet or extra records, such as additional A, AAAA, ALIAS or ANAME records on the apex, or a CNAME on www that points somewhere other than GitHub. GitHub also notes the domain must be under 64 characters. If it stalls, click Remove next to the domain, retype it and save again.
Should I use the apex domain or www?
GitHub recommends www. Its docs say www subdomains are the most stable type of custom domain because they are not affected by changes to GitHub's server IP addresses. Whichever you set as the custom domain, GitHub redirects the other one to it, as long as DNS for both points to GitHub Pages.
How long does a GitHub Pages custom domain take to work?
GitHub says DNS changes can take up to 24 hours to propagate. In practice many records resolve sooner, but plan for a day before you assume something is broken.
Is it safe to use a wildcard DNS record for GitHub Pages?
GitHub strongly recommends against wildcard records such as *.example.com. Its docs say they put you at immediate risk of domain takeover, even if you verify the domain. Create records for the specific subdomains you use instead.
More in Blog
- Use Gmail With a Custom Domain: 3 Ways (2026 Guide)
- GoDaddy DKIM: Set Up CNAME or TXT Records Step by Step
- GoDaddy Domain Appraisal: How It Works and What It Misses
- GoDaddy Domain Forwarding: 301 vs 302, Masking & Steps
- GoDaddy MX Record: Add, Edit and Remove Them (Steps)
- GoDaddy Nameservers: How to Find and Change Them
- GoDaddy TXT Record: How to Add One, Step by Step
- Google AI Studio Vibe Coding: Build, Limits, Deploy
Related guides and tools
Start building
- how to make a website
- AI website builder
- free website builder
- website templates
- website builders by industry
How we research, test and update this page: our editorial policy. We.Inc is our own product.
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App