Setting up a Jekyll Development Environment
Jekyll is a fairly easy tool to get up and running with, but there are so many different ways to configure and use it, that it can be bewildering at first. I know when I was first getting started with it, I was lost.
It was only through trial and error that I ended up finding a solution that worked for me. I have never documented it, though, so I thought I might actually do so, so that I have something to refer back to if I ever need it.
The first step is to get jekyll installed. It’s a pretty simple process, simply fire up a terminal and type
sudo gem install jekyll and enter your password. The Jekyll gem will then download and install itself and all of its dependencies.
You might get some installation errors to start with, which are usually related to the installed version of RubyGems being out of date. If that’s the case, simply update RubyGems by typing
sudo gem update --system and entering your password if asked. Once that’s done, simply try to install Jekyll again, and you should be good to go.
Set up the Site
I don’t have any rakefile or shell script to help me with this1, so I do it manually. I keep all of my sites in my
~/Sites directory, so I’ll open a Finder window and create a new folder for the project in there. Then I’ll add the config.yml and index.html files, along with _posts, _layouts, _includes, assets directories.
I’ll also add a separate output directory alongside with the virtual host URL as the directory name. To make sure that Jekyll puts the compiled site in the right place, I make sure to add a “destination” directive to the config.yml file.
Get Apache Started
We’re going to need a webserver to test the site once we start building, so if the built in Apache webserver isn’t running, I’ll get it started. It’s a simple matter of opening the “Sharing” System Preferences pane, and putting a check in the checkbox next to Web Sharing.
Create Virtual Hosts
I like to use virtual hosts when I’m developing sites, as it makes it easier to access than having to type localhost/some/path/here. There are a whole range of ways to do this, but the easiest that I’ve found is Virtualhostx.
Virtualhostx allows you to share virtual hosts across the local network, the internet, and more. It’s not free, but it’s worth every penny you’ll spend on it.
Now that Jekyll is installed, and I’ve got everything good to go, it’s time to fire up my favourite text editor2, and get to coding.