jekyll site hosted on github project page

Setup the master branch

WARNING: This tutorial covers the setup of a Project Page, and as so the master branch is used as the source one, and the gh-pages branch holds the generated site. However, if you setup a User Page then the master branch holds the generated site, and so you have to create a new branch (eg: source) to hold your site source.

First, create an empty jekyll-example repository on github via the web interface.

Then generate the website:

$ jekyll new [FOLDER NAME]

Init git:


$ git init

$ git add .

$ git commit -m "Generated by Jekyll"

Push master to github:

$ git remote add origin

$ git push -u origin master

Setup the gh-pages branch

Create an orphan gh-pages branch:

$ git checkout --orphan gh-pages

$ git reset .

$ rm -r *

$ rm .gitignore

$ echo 'Coming soon' > index.html

$ git add index.html

$ git commit -m "init"

That way the master and the gh-pages branches are totally independant ones, they share no history at all.

Push gh-pages to github:

$ git push -u origin gh-pages

Now you should see Coming soon message when browsing to:

Let's work in master branch:

$ git checkout master

Checkout the gh-pages branch into _site directory:

$ git clone -b gh-pages _site

The _site directory is already in .gitignore so we are just fine.

Let's test our new website:

$ grunt

Push the generated site on github:

$ cd _site

$ git add .

$ git commit -m "First generation"

$ git push

Now browse to and ... wow... the jekyll site is displayed but the CSS is broken. Why ? Because you have to set the baseurl setting in the main config file.

So edit the _config.yml file and set:

baseurl: "/site-built-with-jekyll-grunt-and-sass"

url: ""

Regenerate the site, and push result on github:

$ cd ..

$ jekyll build

$ cd _site

$ git add .

$ git commit -m "Fixes baseurl"

$ git push

Now browse to and everything should be fine!