Home Blog How to Set Up a Custom Domain for Your Jekyll Site
Tutorial

How to Set Up a Custom Domain for Your Jekyll Site

Connect a custom domain to your Jekyll site on GitHub Pages, Netlify, or Cloudflare Pages — with DNS setup, HTTPS configuration, and www vs apex domain guidance.

How to Set Up a Custom Domain for Your Jekyll Site

Getting your Jekyll site onto a custom domain takes about 10–30 minutes. The process is the same regardless of which registrar you use — you update DNS records and tell your hosting platform about the domain. This guide covers GitHub Pages, Netlify, and Cloudflare Pages.


Before You Start

You need:

  • A domain name (from Namecheap, GoDaddy, Google Domains, Porkbun, or any registrar)
  • Your Jekyll site already deployed to GitHub Pages, Netlify, or Cloudflare Pages

DNS changes take anywhere from a few minutes to 48 hours to propagate globally. Most changes take effect within 30 minutes.


Apex Domain vs www

You have two common choices:

  • Apex domain: yourdomain.com — cleaner, but some DNS providers don’t support ALIAS/ANAME records for it
  • www subdomain: www.yourdomain.com — a standard CNAME works, very reliable
  • Both: redirect www to apex, or apex to www — best user experience

Most modern hosting platforms support apex domains directly. Our recommendation: use the apex domain (yourdomain.com) as primary and redirect www to it.


Option 1: GitHub Pages + Custom Domain

Step 1: Add the CNAME File

In your Jekyll site’s root directory, create a file named CNAME (no extension) containing only your domain:

yourdomain.com

Commit and push this file. GitHub Pages reads it and serves the site at that domain.

Important: If you use GitHub Actions for deployment, include the CNAME file in your _site output or add it to the build step. Otherwise it may get overwritten on each deploy.

Step 2: Configure DNS

In your domain registrar’s DNS settings, add these records:

For an apex domain (yourdomain.com):

Add four A records pointing to GitHub Pages’ 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:

Type Name Value
CNAME www yourusername.github.io

Step 3: Enable in GitHub Repository Settings

  1. Go to your repository → Settings → Pages
  2. Under Custom domain, enter yourdomain.com
  3. Click Save
  4. Check Enforce HTTPS (available after DNS propagates)

Step 4: Verify

GitHub will show a green checkmark once DNS is propagating correctly. Visit https://yourdomain.com — it should load your Jekyll site with a valid SSL certificate.


Option 2: Netlify + Custom Domain

Step 1: Add Domain in Netlify

  1. In Netlify Dashboard, go to your site → Domain management → Add a domain
  2. Enter your domain and click Verify
  3. Click Add domain

Step 2: Configure DNS

Option A: Use Netlify DNS (Recommended)

Transfer your domain’s nameservers to Netlify’s. In Netlify, click Set up Netlify DNS and follow the instructions. You’ll get four nameservers like:

dns1.p01.nsone.net
dns2.p01.nsone.net
dns3.p01.nsone.net
dns4.p01.nsone.net

Update your registrar’s nameserver settings to these four. This gives Netlify full DNS control and enables automatic HTTPS and www→apex redirect.

Option B: Keep Your Existing DNS

Add these records in your registrar:

Type Name Value
A @ 75.2.60.5
CNAME www yoursitename.netlify.app

Step 3: HTTPS

Netlify provisions a free Let’s Encrypt certificate automatically within minutes of DNS propagating. You don’t need to do anything — it just works.


Option 3: Cloudflare Pages + Custom Domain

If your site is on Cloudflare Pages and your domain is on Cloudflare (or you move it there):

Step 1: Add Custom Domain

  1. In Cloudflare Dashboard → Pages → your project → Custom domains
  2. Click Set up a custom domain
  3. Enter your domain and click Continue

Step 2: DNS (if domain is on Cloudflare)

Cloudflare automatically adds the DNS record. Done.

Step 3: DNS (if domain is on another registrar)

Add a CNAME record:

Type Name Value
CNAME @ (or yourdomain.com) yourproject.pages.dev
CNAME www yourproject.pages.dev

Note: Some registrars don’t support CNAME on the apex (@). Use an ALIAS or ANAME record instead if available, or switch to Cloudflare DNS (it’s free and excellent).

HTTPS

Cloudflare provides HTTPS automatically via their edge network. No certificate configuration needed.


Redirecting www to Apex (or Vice Versa)

Users will type both www.yourdomain.com and yourdomain.com. Pick one as canonical and redirect the other.

On Netlify — automatic if you use Netlify DNS. Otherwise add to _redirects:

https://www.yourdomain.com/* https://yourdomain.com/:splat 301!

On Cloudflare — add a Page Rule or Redirect Rule: www.yourdomain.com/*https://yourdomain.com/$1 (301)

On GitHub Pages — add both yourdomain.com and www.yourdomain.com to your CNAME, GitHub handles the redirect automatically.


Update _config.yml

Once your custom domain is live, update your Jekyll config:

# _config.yml
url: "https://yourdomain.com"
baseurl: ""   # Empty for root domain

This ensures all canonical URLs, sitemaps, and Open Graph tags use your custom domain.

Rebuild and redeploy after this change.


Verify Everything Is Working

Check HTTPS:

curl -I https://yourdomain.com
# Should return: HTTP/2 200

Check www redirect:

curl -I https://www.yourdomain.com
# Should return: HTTP/2 301 and Location: https://yourdomain.com/

Check SSL certificate:
Open your site in a browser and click the padlock icon. The certificate should show as valid and issued for your domain.

Check Google Search Console:
Add your domain as a property in Search Console and verify ownership. Submit your sitemap at https://yourdomain.com/sitemap.xml.


Common Issues

Site still showing at username.github.io after setting custom domain
Wait for DNS propagation (up to 48 hours). Check propagation status at dnschecker.org.

HTTPS not working / certificate error
The SSL certificate is provisioned after DNS propagates. Wait 30–60 minutes after DNS is confirmed working.

www not redirecting
You need separate DNS records for www. Add the CNAME for www pointing to your hosting platform.

Jekyll site assets (CSS/JS) not loading after domain change
Update url in _config.yml to your new domain and ensure baseurl is empty. Rebuild and redeploy.


Once your custom domain is set up, your Jekyll site at yourdomain.com is fully production-ready. Browse Jekyll themes on JekyllHub to find a design that represents your brand.

Share LinkedIn