Using GitHub Pages and Jekyll to Host Your Own Blog

Using GitHub pages to setup a flat-file blog is simple and straightforward.

Some of the advantages to using this method include:

  • More performant that using a database-driven approach
  • Easy, pre-configured revision control
  • High uptime with quick page load performance with GitHub’s CDNs
  • Hosting through GitHub can be free (if the source code is set to public)
  • And other benefits that I haven’t even thought of

Two types of GitHub Pages

It is important to be aware that there are two types of GitHub pages available through GitHub:

  • Pages for Organizations (which live on the gh-pages branch), and
  • Pages for Individuals (which live on the master)

This guide will focus on setting up the latter, but the former can be setup using a similar process with a few modifications.

Initialize a Repository

Initialize a repository that follows the following naming convention:

yourusername.github.io

If you’re creating the repository through the GitHub website, be sure to initialize it with a readme file.

Clone it locally

Clone the repository just initialized (if you haven’t already) into a folder on your local machine.

You can do this using the GitHub app or git command line tools.

Create an index.html file

From the root directory of your project, create a file called index.html.

Inside your newly created index.html file, add

1
2
<h1>Everyone Knows It's Butters</h1>
<p><em>That's me!</em></p>

Commit your changes and push them to GitHub, then navigate to http://yourusername.github.io and ensure that the content you just added appears there.