Jekyll Forman Guard Bundler
Sun, 13 May, 2012 (300 Words)This post is a quick “How did I setup my Jekyll environnement ?”. We are going all the tools that are quite awesome in Ruby.
Goal
The goal is simple :
- I want to be able to install any dependent Gem with a on-liner command
- I want to be able to run a Jekyll server that auto updates.
We are going to play with : Bundler, Guard and foreman.
Bundler
Bundler let us run bundle install
to get all Ruby Gems we will need ; It use
a file name Gemfile
. The gems we need are simple : jekyll
, guard
and some
Guard extensions.
source "http://rubygems.org"
gem 'jekyll'
gem 'guard'
gem 'guard-jekyll2'
gem 'guard-shell'
gem 'guard-bundler'
Guard
Guard is a command line tool to easily handle events on file system modifications.
Guard will be watching file we told him and run action in consequence ; The file
is name Guardfile
.
guard 'jekyll2' do
watch %r{.*}
end
guard :bundler do
watch('Gemfile')
end
# vim:filetype=ruby
Foreman
Finally, foreman will let us declare our processes and will handle the start,
forward the output and handle the shutdown. It can then export its configuration
into more production-ready file (init
, upstard
, …) ; It uses a file named
Procfile
.
We will tell foreman to run :
- The jekyll build-in server :
jekyll --server
- Guard, to handle file changes in background.
web: bundle exec jekyll --server
guard: bundle exec guard
And that’s all folk. Now, you just need to run foreman in the Jekyll-powered directory and edit your files.