How to host static website on your domain through Github pages

December 07, 2020

You can host your static webpages through Github absolutely free..did you know that??? If not, don’t worry I am gonna walk you through to the complete process. So let’s get started.

Step 1: Create your website

If you already have one, you can skip this step and if not why not start it today.

For the starters you can make a blog, as it is a simple, easy and a great way to enter world of internet.

A blog is something in which you can share your knowledge with others just like you are reading now. All you have to do deciding on which topic you want to write a blog.

After deciding you can refer to any of these to generate your static blog https://websitesetup.org/best-static-site-generators/ and after your website is complete you are ready to move.

Step 2: Setting up Git in your computer

Downloading Git and installing Git

git-download-page

  • Then, follow the installation steps as you install Git using the installer. For normal installation leave all the checkbox and other options as it is in the installer.
  • You can find more details about installing Git at https://git-scm.com/book/en/v2/Getting-Started-Installing-Git.
  • Installing some of the GUI tools like GitHub desktop will install Git on your computer.
  • On Mac, setting up Xcode command line tools also will set up Git on your computer.
  • You can choose any of the methods mentioned above which you find convenient.

    For the rest of the steps i am assuming you have a GitHub account.

Step 3: Add your site to Git version control

Now you have everything ready to move your blog under version control using git.

Make sure you follow following steps exactly

  • Name your root file as “index.html”. This is important as, if we don’t do this GitHub won’t be able to know from which file it has to start. GitHub finds it by the name “index.html”.
  • Now navigate to root folder in terminal and initialize version control by entring command.

$ git init

Now to add entire project under git tracking by entering:

$ git add

Now it’s a good time to make a commit:

$ git commit -m “initial commit”

After completing this step your site is now under version control.

Step 4: Push your website to Github

Now, we are ready to push to GitHub and running our site live online automatically for free!!

  • Go to github.com and sign in.
  • On your home page click on button says “+New repository”.

git-hub

  • For your page to automatically be hosted, you have to follow a specific nameing convention. Name your repository as “your-username.github.io” and press “create repository” leaving everything else as it is.

new-repository

Now follow GitHub instruction to push your site to your new repository.

Well that’s all you have to do and your new pages should be up at http://Your-username.github.io.

It may take from few minutes to ten minutes at most.