toxinu

Jekyll with Git and Hooks

Posted on 21 October 2011

Good bye my lovely Pyame… Hello Jekyll ! Pyame is my personnal static website creator written in Python under heavy development. These days I searched powerfull, light and easy to use static website creator, and Jekyll is arrived. Thanks God.

In short, these programs parse differents files written in a special syntax, for example : Markdown, Textile, etc. An easy syntax to make your articles or docs more swag. And it generate html output.

I love the usage system of Jekyll, Hyde, Pyame, Bonsai… more here. But the main incovenient thing is that you can’t write articles or docs through your website browser. And you need one of these generator installed on each computer you can potentialy write text.

But ! But ! Jekyll + Git + GitHooks are awesome !

Put your jekyll website into a git repo on your server, git clone it on your desktop, write articles, add, commit, push and githook will automaticaly execute jekyll rendering.

Desktop :

Server :

Jekyll

Jekyll installation is easy like trolling about proprietary software. Docs.

sudo gem install jekyll

Next ? I think you know how to install git instance. There are too many tutorials and docs on the Internet.

Githooks

Githooks are specials scripts which will be execute when git received, a push, a commit, an update… Look at your .git/hooks folder on your server:

socketubs@socket-desktop:~/Repositories/canopsis$ ls -lh .git/hooks/
total 44K
-rwxrwxr-x 1 socketubs socketubs  452 2011-10-21 21:04 applypatch-msg.sample
-rwxrwxr-x 1 socketubs socketubs  896 2011-10-21 21:04 commit-msg.sample
-rwxrwxr-x 1 socketubs socketubs  160 2011-10-21 21:04 post-commit.sample
-rwxrwxr-x 1 socketubs socketubs  552 2011-10-21 21:04 post-receive.sample
-rwxrwxr-x 1 socketubs socketubs  189 2011-10-21 21:04 post-update.sample
...

A short description is present at the top of each files.

This is my post-receive file :

root@socketubs:/srv/gitosis/repositories/socket_site.git/hooks# cat post-receive
#!/bin/sh

echo "-- Attempting to pull and launch jekyll --"
cd /var/www/socket_site
git --git-dir /var/www/socket_site/.git pull file:///srv/.../socket_site.git/ master
jekyll
echo

The pie on the cherry

Just write your files in a beautiful simple syntax with the best text editor ever, VIM, commit and push. Like a Boss.

LOVELY ?