Git & GitHub

How To Add Custom Domain In A GitHub Page

How to Add Custom Domain in GitHub Pages

Most of the time, a git user’s big question is about how to attach a custom domain in a Github page. And it was the same for me also. But now it’s not and that’s why I’ve started writing to them about how you can use a custom domain in your Github page and add Cloudflare also. So, Let’s get started.

Step 1: Get a domain

You need a domain to attach. Buy a domain from any good places like XeonbdGodaddy or any places that you like but make sure it supports custom nameserver. I haven’t found any provider that doesn’t support custom nameserver but also I’d try to mention every bit of information.

I’ve got a domain

Step 2: Set custom nameserver

Your domain needs to point to the Cloudflare server. So, you need to update the nameserver of your domain’s default to below two and make sure other nameserver’s field remains empty without the first two.

I’ve set Cloudflare’s nameserver

Step 3: Create a Cloudflare account and add domain

If you don’t have a Cloudflare account create one. And from ‘add site’ add your domain in Cloudflare. Don’t worry it’s completely free.

I’ve added my domain

Step 4: Update Domain’s DNS from Cloudflare

Now you need to update your domain’s DNS from Cloudflare’s DNS Panel. For every entry, click on ‘Add record’, Select Type ‘A’, enter the domain name in the ‘Name’ field and in the ‘IPv4 address’ field you need to add these four IPs like in the screenshots below. I collected the IP’s from GitHub’s documentation here.

I’ve added all the IP’s of GitHub

Step 4: Finally add your domain to your GitHub page

Go to your Github Repository and from the repository settings, go to Github Pages and there you will have an option for adding a custom domain like the picture below.

I’ve added my domain

It’s working!


So far, I’ve tried to show you everything step by step. If you liked my writing you can inspire me by giving a Clap. You can follow me on Medium and I’m also available on Twitter here. Don’t forget to share your opinion on the comment section below and also the questions if any.

If you like it, share it with others !
Leave a Reply

Your email address will not be published. Required fields are marked *