How to use a custom domain on GitHub Pages
DNS configuration of a GitHub-hosted Jekyll site
If you have a custom domain, you can quickly set it up with your Jekyll site hosted on GitHub Pages. By default, GitHub Pages sites come with domains ending in
github.io. To use your GitHub-hosted site with your custom domain, you only need to configure your DNS (Domain Name System) settings. Then, you can quickly check if your new domain properly works with the help of a DNS-testing service such as LeafDNS.
GitHub lets you host your static website on its servers for free. Since May 2018, it also offers free HTTPS support for custom domains.
I will discuss the most typical use case when you want to point both the apex domain and the
www subdomain to GitHub Pages. The apex domain is the (non-www) root domain without a subdomain, for instance,
annalytic.com for me. There are other, more complicated use cases as well—GitHub Docs detail all of them comprehensively.
There are two places where you need to configure your DNS settings:
- at your domain provider
- in your GitHub repo
1. DNS management in your GitHub account
Go to the Settings page of the GitHub repo of your site and enter your custom domain into the "GitHub Pages" section.
This setting automatically creates a
CNAME record in the root folder of your repo. CNAME stands for Canonical Name and DNS servers use it to alias one domain name to another. You can also make GitHub use HTTPS with your custom domain by ticking the "Enforce HTTPS" checkbox.
2. DNS management at your DNS provider
Log in to your account at your domain provider and navigate to the "DNS Management" (or similarly named) section inside the admin area. Here, you need to do two things:
Arecords that point your apex domain to GitHub Pages' servers. You need to create four
- Create a
CNAMErecord that points the www subdomain to your default GitHub Pages site.
Here are the five DNS records you need to set up:
Host Name Record Type Address
@ A (Address) 22.214.171.124
@ A (Address) 126.96.36.199
@ A (Address) 188.8.131.52
@ A (Address) 184.108.40.206
www CNAME (Alias) yoursite.github.io
Check if everything's all right
You usually have to wait up to 24 hours until the changes propagate. Then, you can check the health of your DNS servers by running a free DNS test with Leaf DNS or a similar provider. You should see something like this:
GitHub also shows a warning if there are any problems with your configuration. That's all.