Free Static Website Hosting on Github with Custom Domain
Overview
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:
- Sign up and create an account on github.com
- Create a public repository for your webpage
- Add website files to the public repository.
- Additionally, one can use a custom domain for their website on Github, i.e., use a personalized domain name instead of the default Github URL.
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
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 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.
Also, create a CNAME DNS record with www.anuragg.in pointing to username.github.io.
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.
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
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
- Your name, rating, website address, town, country, state and comment will be publicly displayed if entered.
- Aside from the data entered into these form fields, other stored data about your comment will include:
- Your IP address (not displayed)
- The time/date of your submission (displayed)
- Your email address will not be shared. It is collected for only two reasons:
- Administrative purposes, should a need to contact you arise.
- To inform you of new comments, should you subscribe to receive notifications.
- A cookie may be set on your computer. This is used to remember your inputs. It will expire by itself.
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
- Although the administrator will attempt to moderate comments, it is impossible for every comment to have been moderated at any given time.
- You acknowledge that all comments express the views and opinions of the original author and not those of the administrator.
- You agree not to post any material which is knowingly false, obscene, hateful, threatening, harassing or invasive of a person's privacy.
- The administrator has the right to edit, move or remove any comment for any reason and without notice.
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Similar content
Past Comments