Skip to Content

Jekyll and Git

I have been using Jekyll for a while now, but all this time I have been generating it on the server, That is, I had had a directory on the server holding the Jekyll files, in which I would run jekyll build to generate the website. Not too streamlined.

Before hosting this weblog on Vultr, I had it on GitHub, and their Pages would do the publishing for me, right after a commit, which was great. Yesterday I decided to implement the same, but on my VPS. This is what I did:

  1. Created empty git repository (git init --bare website.git).
  2. Cloned it.
  3. Added my Jekyll files.

What was left was to add the following post-receive hook1:

#!/bin/bash -l

jekyll build --source $TMP_GIT_CLONE --destination $WWW_ROOT

Now a few seconds right after committing, my website will show the changes. Being able to use Atom with markdown-writer to compose entries, and use git to deploy them is a bliss.

  1. Thanks to Matt Harzewski for pointing me to the right path.