How to Use a Custom Domain with GitHub Pages

In our previous GitHub Pages article, we showed you how you can create a static site and host it in your GitHub repository. This is a simple option for creating a site—with considerable limitations.

Your GitHub Pages site will have its own URL based on your username and the name of the repository. However, you may want to use a custom domain. In this article, we’ll show you how to use a custom domain with GitHub Pages.

Add a Custom Domain to Your Repository

Now, we will need to first add our custom domain to our GitHub repository. This will set up a record there, but the change will not take effect until we add the necessary DNS records to cPanel.

  1. Log into your GitHub account
  2. Select Settings under your repository
  3. Add your custom domain under the Custom domain section and click Save

A custom domain has now been added to your repository. Below, we’ll show how to add an A record in your cPanel that will point to GitHub.

Add A Records to Point Your Domain to GitHub

Now that we have added the necessary domain information to our GitHub account, we are going to create custom domain records in cPanel. This is like adding a physical address to your name in a phonebook. We will be pointing our domain to GitHub’s IP addresses.

  1. Check out our full tutorial on adding an A Record for cPanel
  2. Create one A Record for 192.30.252.153
  3. Create another A Record for 192.30.252.154

If your domain is not pointing to InMotion Hosting, you should be able to add DNS records at your registrar. Once these records have been created, allow at least 4-24 hours for the changes to propagate across the web.

Leave a Reply