Free Static Website Hosting on Github with Custom Domain

Overview

Video tutorial: Free website hosting on Github

This tutorial covers free website hosting on GitHub. The free service comes with a limitation: GitHub can only host static websites built with HTML, CSS, and JavaScript; it does not support server-side processing or database management with MySQL.

The free web hosting service can be used for personal blogs, portfolios, documentation, and simple project sites with static content. Hosting a website on Github involves following steps:

Prerequisite

Mandatory: You should know how to design a website using HTML, CSS and Javascript. This article is not a tutorial on website development; it only describes free hosting of static website on Github.

Flexible: You should have basic knowledge of Github operations such as clone, add, commit, and push, to upload and manipulate files in your repository.

Github

Sign up with a desired username on Github website

To get started with free website hosting, sign up for a new account on Github or sign in to your existing account. Note that your website domain address would be "username.github.io", so choose your username suitably based on your content. Next, you have to create a public repository on GitHub; it should be named "username.github.io" otherwise your website won't work.

Add static website files containing index.html in the respository "username.github.io"

Add your static website files, built with HTML, CSS, and JavaScript, either by uploading them directly through GitHub's interface or by pushing them via Git commands. The website should be live and accessible at username.github.io within a few minutes.

Custom domain

Using a custom domain on GitHub Pages allows you to replace username.github.io with a personalized domain name. This is useful if you desire a professional domain address. Note that domain address purchase comes with an additional cost; it is not free.

Purchase a domain address from a domain registrar

The first step is to acquire a personalized domain address from a domain registrar (e.g., GoDaddy, Bigrock, Namecheap, etc). In this tutorial, I will use the domain name anuragg.in purchased on Bigrock. I would recommend you to research different domain registrar to find the best price for your domain address. Note that some domain registrars sell domain address for cheap for the first year only to charge premium renewal price. Read the terms and conditions carefully before purchase as transferring your domain address to a different registrar can be a costly affair.

Configure DNS settings

As I used Bigrock for my domain address, I will demonstrate how to configure DNS settings on Bigrock.

Log in to your Bigrock account to access the DNS settings for your domain address. Create four different A or ANAME records pointing to the Github IP addresses 185.199.108.153, 185.199.109.153, 185.199.110.153, and 185.199.111.153, respectively.

Managing DNS: A Records
Managing DNS: A Records

Also, create a CNAME DNS record with www.anuragg.in pointing to username.github.io.

Managing DNS: CNAME Records
Managing DNS: CNAME Records

Configure Github

Create a CNAME file in the Github repository. In the file, write the personalized domain name anuragg.in. Once DNS propogation completes, your website will be accessible via your custom domain. It can take up to 48 hours for DNS propogation. To complete the setup of the repository for custom domain, go to Settings → Code and automation tab → Pages and enter your personalized domain (anuragg.in) under the Custom domain section.

Configure custom domain name on Github
Configure custom domain name on Github

Author

Anurag Gupta is an M.S. graduate in Electrical and Computer Engineering from Cornell University. He also holds an M.Tech degree in Systems and Control Engineering and a B.Tech degree in Electrical Engineering from the Indian Institute of Technology, Bombay.


Comment

* Required information
1000
Drag & drop images (max 3)
Captcha Image
Powered by Commentics

Past Comments

No comments yet. Be the first!

Similar content