Curtis Larson's Blog    Main Site    Portfolio     Archive     Feed

How to point a domain on Google Domains to GitHub pages

Table of Contents

  1. Introduction
  2. Setup repository
  3. Configure Google Domains
  4. Conclusion

Introduction

When setting up my website on Google Domains I had to read through several different guides to figure out all I needed to do to point it to a GitHub pages repository. I wrote up this guide to simplify the processes for anyone else performing this same task.

Setup repository

Navigate to https://github.com/new and create a repository with the name USERNAME.github.com or USERNAME.github.io and give it a nice description.

Create a repository

In your new repository, create a CNAME file in the root directory and add the following two entries (with curtismlarson replaced by your own domain):

CName

These two entries tell GitHub to redirect any requests to USERNAME.github.io to the domain specified in the CNAME file. There are two entries to ensure that curtismlarson.com will also redirect to www.curtismlarson.com. If you prefer to have a site without the www prefix, you can switch the order of the domains.

Now verify that your USERNAME.github.io domain is now pointing to your custom domain by going into the repository settings and verifying your GitHub Pages settings:

Github Pages

Configure Google Domains

Navigate to https://domains.google.com/registrar and select the DNS option to configure your DNS records.

Google Domains

Scroll to the very bottom of the page and add 3 Custom Resource Records. You need to add two “@” type A records that point to the GitHub ips 192.30.252.153 and 192.30.252.154 and one “www” CNAME record that points to your USERNAME.github.io url:

Custom Resource Records

Conclusion

That’s it! DNS records often take more than a day to propagate so you may not see your website immediately. Once the changes have propagated your GitHub page and any project pages should be accessible from your new domain. For example https://github.com/quackware/blog is hosting the blog you are reading right now and the domain works without any additional setup.


Curtis Larson is a NYC based freelance software developer. Follow him on Twitter or send him an email if you're looking for a talented developer.