Skip to content

Instantly share code, notes, and snippets.

@kriscooke
Last active February 21, 2021 17:53
Show Gist options
  • Save kriscooke/6bf127a64759d94d57357c307b140a70 to your computer and use it in GitHub Desktop.
Save kriscooke/6bf127a64759d94d57357c307b140a70 to your computer and use it in GitHub Desktop.
GitHub Pages 101 aka. free hosting for all your public demos

GitHub Pages, aka. free hosting for all your public demos:

Without your writing any webserver code, GitHub can recognize specifically-named repos/branches and will serve a static page (including HTML/CSS/JS and other static files) at a certain GitHub-based URL. This means free hosting for your public demos, and makes it really easy to host a doc/demo site associated with each of your repositories. You can even set it up with a custom domain.

User Page (or Organization)

  • Accessible at: yourusername.github.io
  • GitHub automatically reserves this URL for every user and organization to use as their User page, although nothing is published there until you publish.
  • To deploy a static site to this URL:
    1. Create a Github repo with the exact name: yourusername.github.io
    2. Commit an index.html in the root folder to the master branch and push. (From the index page you can link to other folders/files as usual)
    3. Visit yourusername.github.io - tada!

Project Page (for a repo)

  • Has content from any repo that is owned by you - not only what lives in your User page repo
  • Accessible at: yourusername.github.io/your-other-repo/
  • To deploy a static site to this URL:
    1. Create a branch in your your-other-repo repo named gh-pages.
    2. Commit an index.html in the root folder to this gh-pages branch and push.
    3. Visit yourusername.github.io/your-other-repo/

You can make your GitHub Pages site more powerful/organized by taking advantage of the static site generator (Jekyll) that GitHub will run your page through by default, but it is optional. If you haven't included any Jekyll-specific configuration, it will be served exactly as-is.

https://help.github.com/categories/github-pages-basics/

If you want to start making use of Jekyll to take advantage of some conveniences that would normally be handled by a website backend, I recommend this guide:

http://jmcglone.com/guides/github-pages/

http://jekyllrb.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment