Connecting a custom domain and HTTPS to GitHub Pages
Configure DNS A and CNAME records for a custom domain on GitHub Pages, provision a free Let's Encrypt TLS certificate, and update Jekyll's site URL.
Running a technical blog on
<username>.github.ioworks for day one, but migrating to an independent domain protects your search equity and keeps your hosting portable. This guide walks through DNS A and CNAME configuration, GitHub’sCNAMEfile routing, Let’s Encrypt TLS provisioning, and Jekyll URL updates.
Tested with GitHub Pages (GitHub Actions deployment), Jekyll 4.4, and
jekyll-theme-chirpy.
Why move off github.io
GitHub Pages gives you a free <username>.github.io subdomain out of the box. It’s fast to set up, so it makes sense when you’re still testing themes or writing your first few posts. Over the long run, though, staying on a platform subdomain creates three real drawbacks.
First, personal branding. A dedicated domain like namju.kim looks cleaner on a resume, GitHub profile, or conference slide than a generic hosting subdomain.
Second, hosting portability. If you later move from GitHub Pages to Cloudflare Pages, Vercel, or an S3/CloudFront bucket, your URLs stay identical. You only update DNS records at your registrar instead of breaking every link you’ve ever shared.
Third, permanent SEO equity. Search rankings and backlinks accumulate at the domain level. Switching domains two years in forces you to rely on 301 redirects and deal with temporary indexing drops. Starting with your own domain means every post builds value under a hostname you control.
flowchart TD
User["Visitor Browser"] -->|"Requests namju.kim"| DNS["Authoritative DNS"]
DNS -->|"A records (185.199.x.x)"| GHPages["GitHub Pages CDN"]
DNS -->|"CNAME (www -> github.io)"| GHPages
GHPages -->|"HTTPS response (Let's Encrypt)"| User
When not to bother with a custom domain
If the site is a throwaway project demo, internal documentation tied to a specific GitHub organization, or a short-lived experiment, <username>.github.io/<repo> is simpler and free. Paying annual registrar renewal fees only makes sense for a site you plan to maintain for years.
Prerequisites
Before editing DNS records, make sure you have these three items ready:
- A registered custom domain: Purchased from any DNS registrar such as Cloudflare Registrar, Namecheap, Route 53, or a regional registrar (for example,
namju.kim). - DNS zone access: Permission to add and edit
AandCNAMErecords in your domain’s DNS management console. - An active GitHub Pages repository: A working Jekyll/Chirpy repository already deploying to GitHub Pages (for example,
cmsong111.github.io).
Step 1: Configure DNS records for apex and www
To route traffic from namju.kim to GitHub Pages, you point the apex (root) domain to GitHub’s four Anycast IPv4 addresses using A records, and point the www subdomain to your <username>.github.io hostname using a CNAME record.
GitHub Pages official Anycast IPv4 addresses
Register all four addresses rather than just one so traffic benefits from GitHub’s CDN failover and Anycast routing:
185.199.108.153185.199.109.153185.199.110.153185.199.111.153
If your DNS provider supports IPv6 and you want dual-stack resolution, you can also add GitHub’s four AAAA records (2606:50c0:8000::153 through 2606:50c0:8003::153), though IPv4 A records alone are sufficient to pass GitHub’s DNS check.
DNS console entries
Open your DNS management panel and create the following records:
| Record Type | Host / Name | Value / Target | TTL |
|---|---|---|---|
| A | @ (or blank) | 185.199.108.153 | 3600 (or Auto) |
| A | @ (or blank) | 185.199.109.153 | 3600 (or Auto) |
| A | @ (or blank) | 185.199.110.153 | 3600 (or Auto) |
| A | @ (or blank) | 185.199.111.153 | 3600 (or Auto) |
| CNAME | www | cmsong111.github.io | 3600 (or Auto) |
Figure 1. DNS console configuration with GitHub Pages’ four Anycast A records and a www CNAME record.
Different DNS panels represent the apex domain differently. Cloudflare, Namecheap, and most modern registrars accept
@for the root domain (namju.kim), while some older panels expect an empty host field. If you use Cloudflare DNS, set the proxy status to DNS only (gray cloud) during initial certificate issuance so GitHub can verify theArecords directly.
Step 2: Register the custom domain in GitHub and how CNAME works
Once DNS records are saved, tell GitHub Pages which repository owns incoming requests for namju.kim.
- Open your GitHub repository and go to Settings.
- Select Pages in the left sidebar.
- Under Custom domain, enter your apex domain (
namju.kim) and click Save.
Figure 2. GitHub Pages settings panel with the custom domain saved and Enforce HTTPS enabled.
How the CNAME file routes requests
When you save a custom domain in a branch-deployed repository, GitHub creates a CNAME file at the repository root containing a single line:
1
namju.kim
At runtime, GitHub Pages’ edge router inspects the HTTP Host header (Host: namju.kim) and matches it against the repository’s configured domain. If you deploy via GitHub Actions (actions/deploy-pages), the custom domain setting is stored in the repository’s Pages configuration rather than requiring a CNAME file in _site, though keeping a CNAME file in your repo root (or preserving it in your build output) prevents accidental resets if someone switches deployment sources later.
Step 3: Provision Let’s Encrypt TLS and enable Enforce HTTPS
Serving a blog over plain HTTP triggers browser “Not Secure” warnings and hurts search rankings. GitHub Pages integrates directly with Let’s Encrypt to issue and auto-renew free TLS certificates for custom domains.
Enabling Enforce HTTPS
- Right after you save the custom domain, GitHub runs a DNS check against your
Arecords. - Once the DNS check passes, GitHub displays “TLS certificate is being provisioned. This may take up to 15 minutes.” while it completes the ACME HTTP-01 challenge behind the scenes.
- When provisioning finishes, the Enforce HTTPS checkbox becomes clickable.
- Check Enforce HTTPS. GitHub’s edge servers will now issue a
301 Moved Permanentlyredirect fromhttp://namju.kimtohttps://namju.kim.
While DNS records are still propagating, GitHub shows “DNS check in progress” and keeps Enforce HTTPS disabled. Depending on your previous TTL, this can take anywhere from a few minutes to several hours. Don’t repeatedly delete and re-add the custom domain—that resets the ACME provisioning job and slows things down.
Step 4: Update Jekyll’s _config.yml
With DNS and HTTPS active, update Jekyll’s site URL so canonical links, OpenGraph tags, sitemap.xml, and RSS feeds all point to your new domain instead of github.io.
Open _config.yml at the root of your repository and update url and baseurl:
1
2
3
4
5
6
7
# _config.yml
# Protocol and hostname for your site (no trailing slash)
url: "https://namju.kim"
# Empty string when serving from the root of a custom domain
baseurl: ""
Commit and push the change to trigger your GitHub Actions build:
1
2
3
git add _config.yml
git commit -m "chore: update site url to https://namju.kim"
git push origin main
Once the workflow finishes, every internal link and generated feed will reference https://namju.kim.
Verification
Verify both DNS propagation and the live TLS certificate from your terminal and browser.
1. Check DNS propagation with dig
Query your apex domain and www subdomain directly:
1
2
3
4
5
# Verify apex A records
dig namju.kim +noall +answer
# Verify www CNAME record
dig www.namju.kim +noall +answer
A properly propagated setup returns all four GitHub Pages IPs:
1
2
3
4
5
6
; <<>> DiG 9.10.6 <<>> namju.kim +noall +answer
;; global options: +cmd
namju.kim. 3600 IN A 185.199.108.153
namju.kim. 3600 IN A 185.199.109.153
namju.kim. 3600 IN A 185.199.110.153
namju.kim. 3600 IN A 185.199.111.153
You can also confirm that plain HTTP redirects cleanly to HTTPS with curl:
1
curl -ILs http://namju.kim | grep -E "^(HTTP/|location:)"
Expect an initial 301 redirect to https://namju.kim/ followed by HTTP/2 200.
2. Inspect the TLS certificate in the browser
Open https://namju.kim in your browser and click the lock icon in the address bar to view certificate details.
Figure 3. Browser certificate viewer confirming a valid Let’s Encrypt TLS certificate for namju.kim.
Caveats and checklist
Before wrapping up a domain migration, keep these operational details in mind:
- Wait out DNS TTL before troubleshooting: If your domain previously had an
Arecord with a long TTL (such as 86400 seconds), recursive resolvers will cache the old IP until it expires. Lower the TTL ahead of time if you’re migrating an existing live domain. - Automatic apex ↔
wwwredirect: When both the apexArecords and thewwwCNAMErecord are configured, GitHub Pages automatically redirectswww.namju.kimtonamju.kim(or vice versa, depending on which one you entered in Custom domain). - Avoid stale
CNAMEorAAAAconflicts: LeftoverAAAArecords from an old hosting provider cause Let’s Encrypt’s HTTP-01 validation to fail intermittently because ACME prefers IPv6 when present. Remove any oldAAAArecords that don’t belong to GitHub Pages. - Re-register with search consoles: After switching domains, add the new domain property and resubmit
sitemap.xmlin Google Search Console and Bing Webmaster Tools. I covered that exact setup in Setting up SEO, search consoles, and OpenGraph in Jekyll.
Quick migration checklist
- All four GitHub Pages
Arecords added for@andCNAMEadded forwww - Old registrar parking
A/AAAArecords removed - Custom domain saved in Settings → Pages and Enforce HTTPS checked
_config.ymlupdated withurl: "https://<your-domain>"andbaseurl: ""digandcurl -I http://<your-domain>verified after deployment