Blog

Blog post

How to host your website on GitHub for free

Blog post

Not only is GitHub a great place to store and share your code with others but it also offers free web hosting of your website! I was able to launch and host my personal website on Github for free following these simple steps:

1. Create a GitHub account

You will have to create a GitHub account if you do not already have one. You can create an account here. Make sure the user name you select will be the username name you would want your website url to be, preferably your first and last name e.g JohnDoe.

html5 bootstrap template by colorlib.com

2. Create a New Repository

After you have set up your account and signed in, the next thing you have to do is create a new repository. You can see the option to create a new repository on the leftmost panel on your dashboard called repositories. You will find a green button called new, click on it. You will directed to a new page where you would enter information for creating a new repository like repository name, description etc. For your repository name use [username].github.io, where username is your username on GitHub. Make your repository public. See picture below for more details.

html5 bootstrap template by colorlib.com
html5 bootstrap template by colorlib.com

3. Clone New Repository

After creating your new repository, you will find it under the repositories panel of your dashboard. Click on your repository name and it should take you to your repository page. At the rightmost corner of your repository page you can see the option to clone repository. Click on the clone repository button and select the download zip option. This will download a folder to your system, subsequently this folder is where you will place all your website files.

html5 bootstrap template by colorlib.com
html5 bootstrap template by colorlib.com

4. Add files to your cloned website folder using terminal

Launch the terminal on your system. Change directory (cd) till you get to the directory where your cloned repository folder was downloaded on your system. Enter these two commands:

  • cd [username].github.io
  • echo "Hello World" > index.html
html5 bootstrap template by colorlib.com

5. Push and commit your changes

To make the changes you have made to your website folder reflect on your actual website, you will need to add, commit, and push your changes. To do this continue where you left off in your terminal, enter the following commands:

  • git add --all
  • git commit -m "Initial commit"
  • git push -u origin master
  • html5 bootstrap template by colorlib.com

    6. Launch your website

    Your website is ready! Open up any browser of your choice and go to https://username.github.io.You should see the index.html file you added, subsequently you can add new files in the same manner.

    Alternatively, if you use Github Desktop you can follow the steps explained in this blog.