With Github Pages we can host our sites in Github, it is totally free. You can host as many sites as you want. HTML, CSS, Javascripts and Markdown are supported by github pages.

Basically, static sites and project websites are hosted with github. If you want to host any blog sites then you can do with Jekyll too. Check my other posts for Jekyll.

To host any site, I am explaining here from Linux platform, you can use same method for windows too. follow these steps:

You can watch this video or follow the instructions below.

  • login to your github account and create a new repository
  • in terminal navigate to your website’s folder (where index.html is located)
  • run the following github commands:
git init
git add .
git commit -m "your message here"
  • now lets add the remote origin from github
git remote add origin https://github.com/lakshmanbasnet/test.git

** replace lakshmanbasnet with your username ** replace test.git with your repository name

  • the default branch is master, for hosting websites with Github we need to push our files to gh-pages branch. Remember you need to push to this branch since any files pushed to master branch won’t be generated for websites, if you push to gh-pages branch, github will automatically generate website for you.

  • lets make new branch gh-pages with command:

git branch gh-pages
  • lets navigate to our gh-pages branch
git checkout gh-pages
  • now every thing is ready, just hit push command and enter your credentials when asked
git push origin gh-pages
  • after you have pushed your file to github repo, goto your github repo in your browser

  • in settings scroll down to find the link for your website, the link will be something like https://lakshmanbasnet.github.io/test/

  • congratulations your site is live now

  • to make any changes to the website, you need to push the files from your computer to github by following commands:

git add .
git commit -m "your update message"
git push origin gh-pages

To add custom domain name to replace the default domain name provided by github check my next post.

Thanks! Enjoy free hosting!! ;)

Like, comment and Share if I worth :P

Posts you might like

Solved - Reset Wordpress admin password no email, no phpmyadmin access

Didn't get reset email to change wordpress password? No access to phypadmin? Follow this one simple step to reset your wordpress admin password. read more

Solved - Website loading slow because of connecting to gc.kis.v2.scr.kaspersky-labs.com...

Because of some reasons, your website might be slower than it should be. Here is how to fix connecting to gc.kis.v2.scr.kaspersky-labs.com js request injection. read more

Blogging like a Hacker - Jekyll Tutorial

Learn to blog like hacker, Jekyll tutorials from basic installation to deployment, and more advanced stuffs too. read more

Configuring .np domain for Github page

Pointing .np domain to Github page website, Jekyll Website, gh-pages. register.mos.com.np doesn't allow you to add A records to point to Github so here is the most easiest way how... read more

Get a free .me domain with Github Student Developer Pack

Get a free .me domain name in easiest manner from Github Developer Pack. Also with this pack, you will be getting a lot of tools and freebies worthing so much.... read more