Intro
Github pages is easy to setup, but to attach a custom domain with google domains, you may run into problems. Here is how you can do it in 4 steps.
Prerequisites
- You have a github pages repository, e.g. https://github.com/Chun-Yang/Chun-Yang.github.io
- You purchased a domain on google domain, e.g. trentyang.com
STEP 1/4: Let gitHub pages know your custom domain
-
Go to your github repository settings page
-
Add you custom domain name at Settings > GitHub Pages > Custom domain
STEP 2/4: Let your custom domain (trentyang.com) points to your github pages
-
Go to registar page on your google domains, select your domain
-
Go to DNS > Custom resource records
- Add the record shown in the screenshot bellow. Note that you need to use the “+” button to add more urls.
Here is the list of ips in the screenshot:
- 185.199.111.153
- 185.199.110.153
- 185.199.109.153
- 185.199.108.153
Incase these are outdated, you can also find the latest ones at github.
- To confirm that your DNS record is set up correctly, use the dig command to do a lookup of your domain
$ dig trentyang.com +noall +answer trentyang.com. 3600 IN A 185.199.111.153 trentyang.com. 3600 IN A 185.199.110.153 trentyang.com. 3600 IN A 185.199.109.153 trentyang.com. 3600 IN A 185.199.108.153
- Once the above is successful, your custom domain should work correctly. Go to your domain and take a look!
STEP 3/4: Let your www sub-domain (www.trentyang.com) point to your github pages
-
Add the following CNAME record
-
You can use the following dig command to confirm that your setup is correct
$ dig www.trentyang.com +nostats +nocomments +nocmd www.trentyang.com. IN A www.trentyang.com. 1263 IN CNAME chun-yang.github.io.
STEP 4/4: (optional but HIGHLY recommended) Enable HTTPS for your github pages
- Go to your github repository settings page, under Settings > GitHub Pages > Custom domain remove your custom domain and save.
- Then add it back and save again.
- Now you should be able to check the “Enforce HTTPS” checkbox and secure your site!