Add a Custom Domain to Your Github Pages Site

Photo by Richy Great on Unsplash

Add a Custom Domain to Your Github Pages Site

A step-by-step guide to elevating your Github Pages site with your custom domain.

·

2 min read

Github Pages is a great way to host your blog or website for free, but let's be real, a custom domain name is the icing on the cake. So, let's learn how to add a custom domain to your Github Pages site.

First things first, you'll need to have a domain name. If you don't have one yet, you can purchase one from a domain registrar. Once you have your shiny new domain, let's move on to the next step.

  1. You'll need to create a file called "CNAME" in the root of your Github Pages repository. This file should contain only one line: your custom domain name. So, let's say your custom domain is "myawesomeblog.com", the file should look like this:
www.myawesomeblog.com
  1. Now that you've got your CNAME file set up, it's time to make some changes to your domain's DNS settings. This is where things can get a little tricky, but don't worry, you'll make it through this. You'll need to add a CNAME record that points your custom domain to your Github Pages repository. It will look something like this:
Host: www
Points to: <username>.github.io

Make sure to replace <username> with your actual Github username.

Finally, you'll need to wait for the DNS changes to propagate, which can take anywhere from a few minutes to 24 hours. Once the changes have propagated, you should be able to access your Github Pages site using your custom domain.

If you're not comfortable making changes to your DNS settings, you can alternatively point your custom domain to the IP addresses provided by Github, the IP addresses are:

185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153

And that's it! You now have a custom domain for your Github Pages site. Congratulations, you've just leveled up your web development skills! Just remember to be patient while the DNS changes propagate, and don't hesitate to ask for help if you get stuck. And most importantly, have fun!