How to Host Your Website On GitHub Pages For Free
By: Dhrumil Patel
Tags: Website, Github Pages, Web Development, Technology, Github

It’s that simple. You have saved your space on the server and your page live as soon as you hit the create repository button. Want to take a look? Go to the new tab and write your URL address, for me it is — dhrumilcse.github.io. Here is how it looks at the beginning.

Initial Home Page

Now that our page is live, it’s time to bring the original content of our website to the repository. Go to the repository of our website, click on the button upload files, select all the files of your website and hit enter. For the demo, I’ve chosen a free template which only has two files, index.html & style.css, but for you, it might be many more.

Uploading Our Website Files

Once it is uploaded, go to your URL again and see all the changes.

My home page

Using Custom Domains

If you are just like me, you probably don’t like the github.io in your default domain name. No worries. Github Pages let you use your own custom domain name and setting up that is just like walking in the park. If you don’t already have a domain, go buy one. It will cost you probably $1 or $2. And if you already have one, follow the next set of instructions.

Go to your repository setting and add a custom domain name. It will create a CNAME file in your directory, don’t delete it.

Github’s part is done here. Now you need to make changes to your Domain side. Go to the site you purchased your domain, log in and select the domain you want to use, and look for Manage DNS or DNS Settings. I am currently in India and using BigRock as my Domain manager, and here is how my panel looks.

Managing domains

Now, you need to make 2 changes in your DNS.

A records — It is basically an apex domain, which means if any user writes only dhrumil.xyz instead of https://dhrumil.xyz or www.dhrumil.xyz, it will still work.

There are 4 IP addresses you need to used to redirect to the repository. Those are listed below. But please make sure you are using the latest ones by going to the official documentation.

185.199.108.153

185.199.109.153

185.199.110.153

185.199.111.153

A-name record

CNAME — If you want to use www or any other specific sub-domain, you can do that by using CNAME.

We need to point our sub-domain to our primary page which is our repository. Therefore, we will redirect it to dhrumilcse.github.io.

Make sure there is a dot at the end of the address. It is not a typo.

Sub-domain

Now that both are set, it might take up to 24 hours to reflect but usually takes 45 minutes to 1 hour. Once it is done, check your website by typing the custom domain. It’s up and running.

Sub-domain

We just set up a sub-domain but what if you have a blog and you want a separate subdomain like, blog.dhrumil.xyz ?

Is that a case for you? Don’t worry, I’ve got you covered.

Create a separate repository and follow the same procedure from the beginning. Now, go to the control panel of your domain, and add another CNAME record, this time instead of www use blog , and voila, your subdomain is ready to roll.

Note — Make sure you use your sub-domain (name) in the repository settings.