Deploy Jekyll blog to Webfaction via git

Written by
Date: 2013-05-24 17:31:35 00:00

How to install Jekyll on Webfaction


If you want to host Jekyll on Webfaction, you have do it in various ways. The easiest one, might be to generate your site locally and then rsync to a static-only site created on Webfaction.

However, this tutorial considers this assumptions.

  • You are version controlling your site with git
  • You will use git push to deploy your site
  • The site will be generated in Webfaction servers
  • You are using gem 2.0, you can change that.

Install needed software

Prepare your system

You need to install it on your home folder, as you do not have root privileges, add this to your bashrc file

export GEM_HOME=$HOME/gems

Then reload it.

source ./bashrc

Install gems

gem2.0 install jekyll

gem2.0 install RedCloth

Update path

Add this line at the bottom of .bashrc file.

export PATH=$HOME/gems/bin:$PATH

Reload .bashrc file.

source .bashrc

This is everything you need to run Jekyll with markdown documents or textile

Configure git

The idea is to have webfaction's server deploying the site automatically as soon as the committed changes are pushed to it.

Create a bare git repository

mkdir ~/git-repos/my-jekyll-blog.git
cd ~/git-repos/my-jekyll-blog.git
git init –bare

Prepare the post-update hook

vim ~/git-repos/my-jekyll-blog.git/hooks/post-update

It should have these lines

echo “Deploying Jekyll Site”
# Here are the variables
# dont edit below here
DEPLOY_TMP_DIR=$(mktemp /home/user/tmp/jekyll.deploy.XXXXX)
jekyll build -d $DEPLOY_DIR
cd /
# Modify this line to fit your folders
rsync -vrz –checksum -e ssh –delete $DEPLOY_DIR /home/user/webapps/your-site/

The reason to deploy to a temp folder and the rsync to the webapp folder, is to have the creating dates old, that improves caching.


In your local computer:

git remote add webfaction user@webfaction.server:/home/user/git-repos/my-jekyll-blog.git

Push to it, to publish your site:

git push webfaction master