Set a custom domain for GitHub Pages
If you want to have a custom domain for your GitHub Pages, you can follow the steps below.
It is possible to configure one custom domain for each GitHub Pages repository.
Steps
- Goto cloudflare and get a custom domain. In this tutorial, I will use
example.com
. -
In the github repository goto
Settings
->Pages
->Custom domain
and set the custom domain.Note
The custom domain can be the root domain (
example.com
) or a subdomain (www.example.com
orpage.example.com
).- Add the required
A
andAAAA
records to the DNS settings of the custom domain in Cloudflare. The IP addresses for IPv4 and IPv6 can be found in the GitHub Docs - For a root domain (
example.com
), add the following records:- Four
A
record with the Name@
and the IP Addresses185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153
- Four
AAAA
record with the Name@
and the IP Addresses2606:50c0:8000::153
2606:50c0:8001::153
2606:50c0:8002::153
2606:50c0:8003::153
- Four
- For a subdomain (
page.example.com
), add the following records:- Four
A
record with the Namepage
and the IP Addresses185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153
- Four
AAAA
record with the Namepage
and the IP Addresses2606:50c0:8000::153
2606:50c0:8001::153
2606:50c0:8002::153
2606:50c0:8003::153
;; A Records page.example.com. 1 IN A 185.199.111.153 ; cf_tags=cf-proxied:true page.example.com. 1 IN A 185.199.110.153 ; cf_tags=cf-proxied:true page.example.com. 1 IN A 185.199.109.153 ; cf_tags=cf-proxied:true page.example.com. 1 IN A 185.199.108.153 ; cf_tags=cf-proxied:true ;; AAAA Records page.example.com. 1 IN AAAA 2606:50c0:8003::153 ; cf_tags=cf-proxied:true page.example.com. 1 IN AAAA 2606:50c0:8002::153 ; cf_tags=cf-proxied:true page.example.com. 1 IN AAAA 2606:50c0:8001::153 ; cf_tags=cf-proxied:true page.example.com. 1 IN AAAA 2606:50c0:8000::153 ; cf_tags=cf-proxied:true
- Four
- Wait a few minutes for the DNS records to propagate.
- Done! Now you can access your GitHub Pages with your custom domain.
page.example.com
- Add the required