Thursday, December 18, 2014

Hosting Your Website on GitHub for FREE

A lot of people know GitHub as a place where you can share your code with the community. But did you know GitHub also lets you host websites for FREE?

There are two kinds of websites you can host with GitHub, Project Pages and User Pages. Project Pages are for individual repositories you have on GitHub and User Pages are for your entire GitHub account. In this article I will cover Project Pages.

To create a Project Page all you need to do is create a branch on GitHub named gh-pages and anything that you push to that branch will appear on www.github.io (the GitHub Pages domain).

Pretty simple, here's how to do it step by step:

1. Create a gh-pages branch

Open Terminal and go to your local project repository. 

Type  git checkout -b gh-pages
 
2. Push gh-pages up to github.io

Type  git push origin gh-pages

3. Wait up to 30 minutes...


Go to [username].github.io/[respositoryname] to see your site.

For example, my GitHub username is af19 and I have repository called typetool. So, the URL is af19.github.io/typetool

And that's that.  

One limitation of GitHub Pages is that you can't have any server-side stuff on there. That means no Ruby, PHP, Python, etc. So just HTML, CSS and JavaScript.

1 comment: