DNS Setup for GitHub Pages
How to Point Your Domain to GitHub Pages
This guide walks you through the process of configuring your custom domain to point to your GitHub Pages site.
Step 1: Configure GitHub Pages Settings
- Navigate to your repository on GitHub
- Go to Settings → Pages
- Under "Custom domain", enter your domain name (e.g.,
example.com
) - Click Save
Note: GitHub will create a CNAME file in your repository root. Don't delete this file.
Important: Do NOT enable "Enforce HTTPS" yet. This must be done after DNS configuration is complete and verified.
Step 2: Configure DNS Records
The DNS configuration depends on whether you're using an apex domain (example.com) or a subdomain (www.example.com).
For Apex Domains (example.com)
Create the following A records in your DNS provider:
Type: A Name: @ Value: 185.199.108.153
Type: A Name: @ Value: 185.199.109.153
Type: A Name: @ Value: 185.199.110.153
Type: A Name: @ Value: 185.199.111.153
Also create a CNAME record for the www subdomain:
Type: CNAME Name: www Value: yourusername.github.io
For Subdomains (www.example.com)
Create a single CNAME record:
Type: CNAME Name: www Value: yourusername.github.io
Step 3: Common DNS Providers
Cloudflare
- Go to DNS → Records
- Add A/CNAME records as above
- Set Proxy status to "DNS only" (gray cloud)
Namecheap
- Go to Advanced DNS
- Add A/CNAME records
- TTL can be set to Automatic
GoDaddy
- Go to DNS → Manage Zones
- Add A/CNAME records
- Use @ for apex domain
Route 53 (AWS)
- Go to Hosted Zones
- Create A/CNAME records
- Use root domain for Name field
Step 4: Verify DNS Configuration
- Visit your domain to confirm it loads your GitHub Pages site
- Wait for DNS propagation (can take up to 24 hours, usually much faster)
- If needed check DNS propagation at whatsmydns.net
Step 5: Enable HTTPS (After DNS is Working)
Only proceed with this step after your domain is successfully loading your GitHub Pages site.
- Return to your repository's Settings → Pages
- Refresh the page to update the DNS check status
- Verify that GitHub shows "DNS check successful" or similar confirmation
- Now check "Enforce HTTPS"
- Click Save
- Wait for SSL certificate provisioning (can take several hours)
- Verify HTTPS is working by visiting your site and checking for the padlock icon
Troubleshooting
Site not loading?
- Check that DNS records are correct
- Wait for DNS propagation (up to 24 hours)
- Verify the CNAME file exists in your repository
HTTPS not working?
- Ensure "Enforce HTTPS" is enabled in GitHub Pages settings
- Wait for SSL certificate provisioning (can take several hours)
- Try disabling and re-enabling "Enforce HTTPS"
Testing Commands
Use these commands to test your DNS configuration:
# Check A records
dig yourdomain.com A
# Check CNAME records
dig www.yourdomain.com CNAME
# Check from specific DNS server
dig @8.8.8.8 yourdomain.com A
Success! Once configured properly, your custom domain will point to your GitHub Pages site with HTTPS enabled automatically.