Categories

Deploy Jekyll blog to Webfaction via git

Written by Guillermo Garron .
Date: 2013-05-24 17:31:35 -0400

How to install Jekyll on Webfaction

Introduction

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

#!/bin/bash
echo “Deploying Jekyll Site”
# Here are the variables
REPOSITORY_DIR=”/home/user/git-repos/my-jekyll-blog.git”
DEPLOY_DIR=”/home/user/tmp/jekyll-temp/”
# dont edit below here
DEPLOY_TMP_DIR=$(mktemp /home/user/tmp/jekyll.deploy.XXXXX)
rm -f $DEPLOY_TMP_DIR
git clone $REPOSITORY_DIR $DEPLOY_TMP_DIR
cd $DEPLOY_TMP_DIR
jekyll build -d $DEPLOY_DIR
rm -rf $DEPLOY_TMP_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.

Deploy

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
permalink

If you enjoyed the article, please share it

twitter | facebook | google+ | linkedin | email | reddit


comments powered by Disqus

Sponsor

Bio.

My name is Guillermo Garron. I am telecommunications engineer from Bolivia

I like technology a lot, and this site is mainly dedicated to that

Social feeds

rss | twitter | email | google+

Posts via email

If you use the letter icon above and subscribe to my tinyletter newsletter, you will get one to two emails, related to this site, or not. If what you want is to get the posts of this site via email, use the form below

Enter your email address:

Delivered by FeedBurner