Using a custom domain name can be important for personal marketing and offers one greater freedom to in choosing their domain representation (GitHub Pages requires the domain name
Purchasing a domain name
Go to domains.google.com and purchase whatever domain you want ($12 / year usually).
Create a file called CNAME in the main directory of your github repo. Add the lines
Open up the DNS settings for your site on https://domains.google.com/registrar.
Under “Name servers”, click “Use the Google Domains name servers”.
Under “Custom resource records”, create the following records:
- @, A, 1h, 220.127.116.11, (click the + button) 18.104.22.168, (click the + button) 22.214.171.124, (click the + button) 126.96.36.199
- www, CNAME, 1h,
https://<your_username>.github.io/.<your_domain_name>.These records tell Google’s DNS to point to GitHub to find your page.
Securing your site with HTTPS
By default, github pages doesn’t support access to your site with HTTPS with a custom domain. This means that whenever someone clicks on your site after a google search, they’ll see a warning saying your site might be trying to steal your data. We don’t want this!
Set up a free cloudflare account here: https://www.cloudflare.com/ and add your website to your account.
Under the DNS settings for your site on Cloudflare, go to “DNS Records”.
- Set up the following DNS Records:
<your_domain_name>, 188.8.131.52, Automatic TTL
<your_domain_name>, 184.108.40.206, Automatic TTL
<your_domain_name>, 220.127.116.11, Automatic TTL
<your_domain_name>, 18.104.22.168, Automatic TTL
- CNAME, www,
<your_domain_name>should be like
- Scroll down to Cloudflare Nameservers and take note of the two nameservers provided to you.
- Some examples are lorna.ns.cloudflare.com and phil.ns.cloudflare.com.
Under the Crypto settings for your site on Cloudflare, scroll to “SSL” and ensure that Full SSL encryption is being used.
Scroll to “Always use HTTPS” and flick the switch to “On”.
Go back to the DNS settings at https://domains.google.com/registrar and go to “Name servers”.
- Click “Use custom name servers” and input the two name servers provided to you by Cloudflare.