GitHub Pages hosts your web app globally for free in 10 min

How do you set up scalable hosting for a global web app for free in <10 minutes?


The time to set up a new dev project has gone from hours a few years ago to days now with the combination of node, nginx, python libs, apt-get, hosting services, dev environments, etc. One part that has always been a hidden challenge is getting your project live on the web and hosted in a way people can access it.

In the past, when most systems needed a direct apache / php server to host a site, the obvious answer was to boot one up. Now, with server-less one-page apps based on angular.js and react.js, it is no longer necessary (or a good thing) to host it on your own server as the SLA is much lower than on a huge hosting service. The only challenge is which one, how to set it up and how to create a deploy process for it.

A little while ago, GitHub took their README.md files and started making them available on a sub-domain for each account such as:

Example of a readme: https://hcl337.github.io/ancilla/

Example of a react.js app: https://hcl337.github.io/ancillawebclient/


What they also allow is for you to point it at any web page in the branch of your repository. That means that you can point it to a react, angular or other starting page and it will load that website just like a readme file. Voila... free and simple hosting.

Here is the quick overview: https://pages.github.com/

React.js tutorial is here which explains how to do it with 'create-react-app' from facebook. The simple implementation is to:

  1. Create a branch - they have 'gh_pages' as theirs.
  2. Set the GitHub Pages branch to 'gh_pages'.
  3. Set up a build script which compiles the app and creates an index.html file as the core starting page with assets in a sub-directory. (See image below)
  4. Build/Deploy each time you want to deploy something.