Jekyll Auto-Build With Git Hooks

 ·  1 minute, 41 seconds

tl;dr: Use the full path to your jekyll executable when running it from a git hook.

As much as I love Jekyll for it's nerdiness and it's speed, as much can it be annoying at times when you have to "compile" your website and upload it to your server every time you fix a comma. This situation lends itself to get automated.

First things first: I host my website on Uberspace. I mentioned before that they're just the best, right1? Anyway, at Uberspace, they don't have Jekyll pre-installed so you have to install it yourself. And since you can't just install it for the entire machine, you have to install it on a per-user basis:

gem install --user jekyll

This allows you to still run jekyll from the terminal as you normally would. However, this doesn't seem to apply when working executing a post-receive git hook included in your server repository.

Therefore, I had to enter the full path2 to the jekyll executable to the example provided on the official Jekyll site. So, what I ended up with looks like this:


~/.gem/ruby/1.9.1/bin/jekyll build -s $TMP_GIT_CLONE -d $PUBLIC_WWW

I assume that this applies to any setup where you're not able to install software on a machine-level but only on your user account. So feel free to drop me a line if this helped you, even with another setup.

If you can see this post, this means that this system is working as intended.

  1. They operate on a pay-what-you-want basis and offer a shit-ton of features. Besides, their support is insane. And I mean that in the best possible way. 

  2. If you don't know how to find that full path just run which jekyll

Related Pages: Back…