{
"$type": "site.standard.document",
"description": "How I configure GitHub Pages with both an apex domain and www subdomain, including DNS entries, domain forwarding, HTTPS, and verification commands.",
"path": "/notes-github-pages-apex-and-www-domain/",
"publishedAt": "2021-02-28T05:15:00.000Z",
"site": "at://did:plc:bryys25pc2fnagnyxqgsglhd/site.standard.publication/3mn26bjkkmh23",
"tags": [
"Tools"
],
"textContent": "This is about configuring both an apex domain and www subdomain for GitHub Pages. I migrated this site to Jekyll and GitHub Pages previously.\n\nThe setup I want:\n\n * example.com is the canonical domain in GitHub Pages\n * www.example.com forwards to example.com\n * HTTPS works for both\n\nThe steps:\n\n 1. Configure GitHub Pages in the repository settings.\n 2. Set the custom domain as the apex domain, e.g. example.com.\n 3. In the DNS provider, add a CNAME record for www -> <username>.github.io. Yes, just the user or organization domain. Do not include the repository name.\n 4. For the apex domain, add either ALIAS/ANAME for example.com -> <username>.github.io, or use GitHub Pages A records if your DNS provider does not support ALIAS/ANAME.\n 5. Set a low TTL while testing.\n 6. Verify curl -I https://example.com returns content correctly.\n 7. Verify curl https://example.com shows a redirect\n 8. For www, verify curl -I https://www.example.com points back to https://example.com.\n 9. Enable \"Enforce HTTPS\" in GitHub Pages once GitHub has issued the certificate.\n 10. Set a higher TTL.\n\nGitHub's current docs also recommend verifying the custom domain before adding DNS entries. That prevents someone else from attaching one of your domains or subdomains to their repository while DNS is already pointed at GitHub Pages.\n\nUseful checks:\n\ndig example.com +noall +answer -t A\ndig www.example.com +noall +answer\ncurl -I https://example.com\ncurl -I https://www.example.com",
"title": "Notes on Configuring Both Apex and www Subdomain for GitHub Pages",
"updatedAt": "2026-05-23T00:00:00.000Z"
}