Custom Domain Setup
By Amr
Configure a custom domain for your Jekyll site hosted on GitHub Pages or Netlify.
Estimated reading time: 4 minutes
Table of Contents
Custom Domain Setup
Configure a custom domain for your Jekyll site.
Overview
Using a custom domain gives your site a professional appearance and makes it easier for visitors to remember your URL.
Prerequisites
- A domain name from a registrar (GoDaddy, Namecheap, Google Domains, etc.)
- Your site deployed to GitHub Pages or Netlify
GitHub Pages Setup
Step 1: Configure Repository Settings
- Go to your repository on GitHub
- Navigate to Settings → Pages
- Under Custom domain, enter your domain (e.g.,
example.com) - Check Enforce HTTPS
- Click Save
This creates a CNAME file in your repository.
Step 2: Configure DNS
Add these DNS records at your domain registrar:
For Apex Domain (example.com)
Add A records pointing to GitHub’s IP addresses:
| Type | Name | Value |
|---|---|---|
| A | @ | 185.199.108.153 |
| A | @ | 185.199.109.153 |
| A | @ | 185.199.110.153 |
| A | @ | 185.199.111.153 |
For www Subdomain
Add a CNAME record:
| Type | Name | Value |
|---|---|---|
| CNAME | www | username.github.io |
Replace username with your GitHub username.
Step 3: Verify Configuration
- Wait for DNS propagation (can take up to 48 hours, usually faster)
- Visit your custom domain
- Check that HTTPS is working (padlock icon in browser)
Step 4: Update Jekyll Configuration
Update _config.yml:
url: "https://example.com"
baseurl: "" # Empty for apex domain
Netlify Setup
Step 1: Add Custom Domain in Netlify
- Go to Site settings → Domain management
- Click “Add custom domain”
- Enter your domain (e.g.,
example.com) - Click Verify and Add domain
Step 2: Configure DNS
Netlify provides two options:
Option A: Netlify DNS (Recommended)
- In Domain management, click “Set up Netlify DNS”
- Update nameservers at your registrar to:
dns1.p01.nsone.netdns2.p01.nsone.netdns3.p01.nsone.netdns4.p01.nsone.net
- Netlify automatically configures all records
Option B: External DNS
Add these records at your registrar:
| Type | Name | Value |
|---|---|---|
| A | @ | 75.2.60.5 |
| CNAME | www | your-site.netlify.app |
Step 3: Enable HTTPS
- In Domain management, scroll to HTTPS
- Click “Verify DNS configuration”
- Click “Provision certificate”
Netlify uses Let’s Encrypt for free SSL certificates.
Common DNS Configurations
Apex Domain Only (example.com)
A @ 185.199.108.153
A @ 185.199.109.153
A @ 185.199.110.153
A @ 185.199.111.153
www Only (www.example.com)
CNAME www username.github.io
Both Apex and www
A @ 185.199.108.153
A @ 185.199.109.153
A @ 185.199.110.153
A @ 185.199.111.153
CNAME www username.github.io
Redirect www to Apex (or vice versa)
Configure a redirect in your hosting platform:
Netlify (netlify.toml):
[[redirects]]
from = "https://www.example.com/*"
to = "https://example.com/:splat"
status = 301
force = true
Domain Registrar Guides
GoDaddy
- Log in to GoDaddy
- Go to My Products → DNS
- Click Manage next to your domain
- Add/edit DNS records as shown above
Namecheap
- Log in to Namecheap
- Go to Domain List → Manage
- Click Advanced DNS
- Add records under Host Records
Google Domains
- Log in to Google Domains
- Select your domain
- Click DNS in the left menu
- Add custom records
Cloudflare
- Log in to Cloudflare
- Select your domain
- Go to DNS tab
- Add records (set Proxy status to DNS only for initial setup)
Troubleshooting
DNS Not Propagating
- Wait up to 48 hours (usually much faster)
- Check propagation status: dnschecker.org
- Clear DNS cache:
- macOS:
sudo dscacheutil -flushcache - Windows:
ipconfig /flushdns
- macOS:
HTTPS Not Working
- Verify DNS records are correct
- Wait for SSL certificate provisioning
- Check for mixed content warnings in browser console
- Ensure all resources use HTTPS URLs
Site Shows Wrong Content
- Clear browser cache
- Check
urlandbaseurlin_config.yml - Verify CNAME file exists (GitHub Pages)
- Rebuild and redeploy
Certificate Errors
- Ensure domain points to correct hosting
- Wait for certificate provisioning (can take hours)
- Check for CAA records that might block certificate issuance
Best Practices
- Always use HTTPS — Protects visitors and improves SEO
- Choose a canonical URL — Redirect www to non-www (or vice versa)
- Update all references — Ensure
_config.ymland any hardcoded URLs match - Test thoroughly — Check all pages after domain change
- Set up monitoring — Use uptime monitoring for production sites