How to use a Custom Domain with GitHub Pages FREE (Not the Domain)

How to Use a Custom Domain with GitHub Pages

So you’ve deployed your website using GitHub Pages, and you have a URL like your-username.github.io/my-cool-project. That’s great! But what if you want it to be accessible at a professional domain you own, like my-cool-project.com or www.my-cool-project.com?

This guide will walk you through the entire process of connecting a custom domain you’ve purchased to your GitHub Pages site.


Prerequisites

Before you begin, you need two things:

  1. A deployed GitHub Pages site: Your website should already be live at its github.io address.
  2. A custom domain name: You must have already purchased a domain from a registrar like GoDaddy, Namecheap, Google Domains, etc.

Part 1: Configure Your Domain in GitHub

First, we need to tell GitHub which domain you’re going to use.

  1. Navigate to the GitHub repository for your website.
  2. Click the “Settings” tab.
  3. In the left sidebar, click on “Pages”.
  4. Scroll down to the “Custom domain” section.
  5. In the text box, type your custom domain name (e.g., www.yourdomain.com or yourdomain.com) and click “Save”.

After you save, GitHub will try to verify your domain. It will likely fail at first because you haven’t configured your domain’s DNS yet. GitHub will show you the records you need to add, but we’ll cover that in the next step.

Note: A file named CNAME will automatically be created in your repository. This is normal and necessary—do not delete it!


Part 2: Configure Your DNS Records

This is the most important step. You need to go to your domain registrar’s website (where you bought the domain) and point it to GitHub’s servers.

  1. Log in to your domain registrar’s website (GoDaddy, Namecheap, etc.).
  2. Find the DNS management page for your domain. It’s often called “DNS Settings,” “Manage DNS,” or “Advanced DNS.”
  3. You will need to add DNS records. The type of records you add depends on the type of domain you are setting up.

Option A: Setting up a www Subdomain (e.g., www.yourdomain.com)

This is the most common and recommended method.

You need to create a CNAME record.

  • Type: CNAME
  • Host / Name: www
  • Value / Points to: your-username.github.io (replace your-username with your actual GitHub username).
  • TTL: You can leave this at the default setting (usually “1 hour” or “Automatic”).

Delete any other A or AAAA records for the www host if they exist.

Option B: Setting up an Apex Domain (e.g., yourdomain.com)

An apex domain is the root domain without www. If you want your site to be accessible at yourdomain.com, you must use A records.

You need to create four separate A records pointing to GitHub’s IP addresses.

Create the first record:

  • Type: A
  • Host / Name: @
  • Value / Points to: 185.199.108.153
  • TTL: Leave at default.

Now, create three more A records, each with the same Host (@) but with the following values:

  • 185.199.109.153
  • 185.199.110.153
  • 185.199.111.153

When you are finished, you should have four A records all with the host @ pointing to those four different IP addresses. Delete any other A or AAAA records for the @ host if they exist.


Part 3: Wait for DNS Propagation

DNS changes are not instant. It can take anywhere from a few minutes to several hours (in rare cases, up to 48 hours) for your changes to take effect across the internet.

You can check the status by going back to your repository’s Settings > Pages page. GitHub will eventually show a green checkmark and the message “Your site is published at…” once the DNS is configured correctly.

You can also use a tool like whatsmydns.net to check if your domain is pointing to GitHub’s IP addresses.


Part 4: Enforce HTTPS

Once your site is live at your custom domain, a final crucial step is to secure it.

  1. Go back to your repository’s Settings > Pages page.
  2. Scroll down to the “Custom domain” section.
  3. You should now see a checkbox labeled “Enforce HTTPS.”
  4. Check this box.

This ensures that all traffic to your site is encrypted and secure, showing the padlock icon in the browser’s address bar. This option will only become available after your custom domain is successfully connected.

And that’s it! Your GitHub Pages site is now live on your professional custom domain.

@ars18 maybe reply how you used nginix reverse proxy


If you have any suggestions or edits, please reply below.

And if you found this helpful, a :+1: would be much appreciated!

5 Likes

Nginx is a whooooolllee topic within itself, which I am not prepared to guide for lol. I only know what I need to know.

Also, MANY uses aside from this.

1 Like

Why?

Serious question.

Not sure If I remember I’ll check tomorrow if its needed