Blogging with Jekyll and Git

Posted: June 26, 2011 by Ryan Bright

Jekyll

In recent years, social media like Twitter and Facebook have allowed me to communicate my ideas in small, palatable bites of information. This format was revolutionary (no pun intended) for the conflicts in Egypt and Iran, and it’s allowed me to bitch about traffic and my university with stunning efficiency. Though, there are still times when I’d like to convey a longer or more complex message to the handful of people that might stumble upon my web presence. While Tumblr has served as a happy medium for some, I don’t feel that we’ve fully eluded the need for traditional, robust blogging platforms like WordPress and TypePad.

But I don’t want to use WordPress. I may dabble in the art of spewing my thoughts and opinions on the Internet, but let’s face it – I’m a programmer. For me to write paragraphs of content that may never be read by another human being, my platform needs to be covered in peanut butter to hide the fact that I’m generating content written in human-readable language. Enter Jekyll.

Jekyll is a static site generator that allows me to build my blog using the tools that are already a part of my daily workflow – MacVim, Git, and Ruby. All markup, styling, and extensions are written using my own tools, so I can be sure that the only spaghetti code being generated on my pages will be something that I have written myself. Additionally, I’m able to manage the content on my blog by tossing it all into a Git repository that can be pushed to my server. There’s nothing quite like “git reset –hard” to crumple a sheet of digital paper, eh?

Many people have written about how to migrate from WordPress to Jekyll, so I won’t bother trying to oust these great tutorials. However, if you’d like to integrate Git into your Jekyll workflow, I’ve provided a simple shell script to help you get started. The script is executed each time a push is made to the remote repository.

Note: I’m assuming that you’ve installed the Jekyll gem on your server along with all of its dependencies. Additionally, you might want to setup Gitolite to simplify management of your repositories.

#!/bin/sh
# File: $HOME/repositories/ryanbright.me.git/hooks/post-receive
export GEM_HOME=/usr/local/rvm/gems/ruby-1.9.2-p290

GIT_REPO=$HOME/repositories/ryanbright.me.git
TMP=/tmp/ryanbright.me
PUBLIC_HTML=/srv/www/ryanbright.me/public_html
JEKYLL=/usr/local/rvm/gems/ruby-1.9.2-p290/bin/jekyll

rm -Rf $TMP
rm -Rf $PUBLIC_HTML/*
git clone $GIT_REPO $TMP
$JEKYLL --no-auto $TMP $PUBLIC_HTML
chmod -R 755 $PUBLIC_HTML/*
rm -Rf $TMP

exit

I’m looking forward to digging more into Jekyll throughout the coming weeks, but I’m happy to have my blog up and running for now – WordPress free. If you’re in the market for a lightweight, customizable blogging system, give Jekyll a try!

Comments

blog comments powered by Disqus