loading...

How to setup google domain for github pages

trentyang profile image Trent Yang Updated on ・3 min read

google domains and github pages

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

STEP 1/4: Let gitHub pages know your custom domain

  • Go to your github repository settings page
    GitHub Settings

  • Add you custom domain name at Settings > GitHub Pages > Custom domain
    GitHub Settings Github Pages

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
    Google Domain Register

  • Go to DNS > Custom resource records
    DNS Custom resource records

  • Add the record shown in the screenshot bellow. Note that you need to use the "+" button to add more urls.
    A record
    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
    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. GitHub Settings Github Pages
  • Then add it back and save again.
  • Now you should be able to check the "Enforce HTTPS" checkbox and secure your site!

If you enjoy reading it, here is my blog https://trentyang.com/how-to-setup-google-domain-for-github-pages/

Discussion

pic
Editor guide
Collapse
sayakpaul profile image
Sayak Paul

Hello. Thanks for the amazing tutorial. A couple of questions:

Here's the output of the dig:

$ dig www.sayak.dev +nostats +nocomments +nocmd

; <<>> DiG 9.10.6 <<>> www.sayak.dev +nostats +nocomments +nocmd
;; global options: +cmd
;www.sayak.dev.         IN  A
www.sayak.dev.      380 IN  CNAME   sayakpaul.github.io.
sayakpaul.github.io.    379 IN  A   185.199.108.153
sayakpaul.github.io.    379 IN  A   185.199.109.153
sayakpaul.github.io.    379 IN  A   185.199.110.153
sayakpaul.github.io.    379 IN  A   185.199.111.153

When I navigate to sayak.dev, I get the following:

My Google Domain settings are correct as well I think:

Help appreciated :)

Collapse
marinadelkovamoro profile image
Marina Delkova-Moro

Hello,

I am stuck on step 2 and having trouble adding the IPs to my Custom resource records on Google domain. I get a notification "Record already in use" for the IPs that you have provided in this article and I can't figure out what are the updated ones. I have been reading through GitHUb documents for the last few hours and can't seem to find the current IPs.

Can you, please, provide the current IPs?

Thank you!!

Collapse
kellymtrinh profile image
Kelly

I got this error when I still had a subdomain forwarding on under Synthetic records. It went away after I deleted that!

Collapse
marinadelkovamoro profile image
Marina Delkova-Moro

Thanks, Kelly!! This makes sense now!

Collapse
angoodkind profile image
Adam Goodkind

When I enter the dig command in Step 3, I only get the same 4 IP addresses from Step 2, and do not get a CNAME result. What have I configured incorrectly?

Collapse
enzotrompeneers profile image
Enzo Trompeneers

Same problem, any solution?

Collapse
angoodkind profile image
Adam Goodkind

Unfortunately I do not remember, but it did eventually work. I think you need to make sure there's only 1 entry on that page. In addition, things usually take 10-15 minutes to propagate through the system.

Collapse
brpetrucci profile image
Bruno do Rosario Petrucci

Hi, thanks for the great tutorial! I'm getting an error, not sure where.

Everything seems to be working correctly - dig commands lead to the same output you show, the website shows up with a check in github "ready to be published at brpetrucci.com" etc, but when I try the URL it says the page cannot be found? I'm very confused

Collapse
dannydore profile image
Danny Dore

I just want to say thank you for making this! I was having trouble figuring out how to connect Google Domains and GitHub Pages, but your guide was the tutorial I needed!

Collapse
dulani profile image
Dulani

Very helpful! I was mistakenly treating the "Registered Hosts" as the A record and the "Synthetic Domain" as the CNAME record. Your clear and concise post straightened me out!

Collapse
thecarpathiancoder profile image
TheCarpathianCoder

Thanks man!

Collapse
knpfletcher profile image
Karen Fletcher

This article is awesome, the most straightforward and thorough outline of the process! Thanks for posting!

Collapse
jakkapanksb profile image
Jakkapan

Thanks, Absolutely nice tutorial

Collapse
fuhrmann profile image
Ricardo Fuhrmann

Thanks, it worked!

Collapse
whatsappwebsingapore profile image
whatsappweb-singapore

You are a life-saver! Thank you so much!

Collapse
vincentlegoualher profile image
Vincent Le Goualher

Thank you very much ! You'd think this kind of thing would be trivial by now, but it is still not :)