Blogging Like A Boss
What are you doing when you write a blog post about blogging? You’re blogging like a boss .
Recently I discovered jekyll, a ruby framework for static HTML site generation, and tried using it to generate my blog. I felt compelled by its simplicity and transparency, and within hours had replaced my wordpress installation with my very-own hand-crafted jekyll blog.
And this is all it took to get me hooked:
$> gem install jekyll
In this post I will document how, in short order, I had jekyll generating my blog to static html from my Mac OS X machine to my shared web host with nearly zero effort.
What is Jekyll
Simply put: it’s a ruby framework for static HTML site generation. If you’re a ruby web programmer, you’ll be delighted to see that there is no black box in jekyll. It has a few simple conventions about where to put files. It uses liquid for its template engine. Everything else is up to you. Jekyll coins this simplicity: “blogging like a hacker”.
Here’s a quick overview of how I got jekyll running on my machine:
- Install jekyll gem
- Create simple folder structure based on install instructions
- Run jekyll server in “auto mode”:
jekyll --server --auto - Navigate to
localhost:4000 - Blog by writing textile or markdown files in
_posts/
Syntax Highlighting: Pygment
Since I mostly write about ruby and rails topics, syntax highlighting is key. I was using a plugin for syntax highlighting in wordpress, but that is no longer necessary with jekyll.
Out of the box, jekyll uses Pygment for syntax highlighting. You do have to install it, but it could’t be easier. Here is all it took me to install on Mac OS X 10.6:
$>sudo port install python25 py25-pygments
Once that completed, I simply set pygment to true in jekyll’s _config.yml, and had easy syntax highlighting in my liquid templates.
There are excellent install instructions for pygment on jekyll’s install page
Deploying to my Shared Hosting with Rake
The jekyll wiki outlines a few excellent deployment strategies on their deployment page. Since I have shared hosting with ssh access, I chose to deploy via rsync with the following rake task:
task :deploy do
exec("jekyll && rsync -avz --delete _site/ you@yourserver:path")
end
Any time I want to change the layout or content on my blog, i just run rake deploy. In the meantime, I have the entire blog running locally on my machine allowing me to preview the entire site before putting it live.
RSS Syndication
To get my blog syndicated via Atom, I simply created an atom.xml file in my root folder, borrowed some inspiration from Git Ready’s open-source atom.xml liquid template on github, re-deployed and had atom-compatible syndication of my new jekyll blog.
Et Voila
Aside from the usual iterative styling, and learning about jekyll’s built-in template data in order to create my liquid templates, that’s really wall it took to take control of my blog with jekyll.
The main wins for me are:
- it’s static HTML, so it’s fast and very cacheable
- I can build-in as much (or as little) complexity I want
- I can preview the entire site before updating anything
If you’re a web programmer it is definitely worth taking a look at jekyll
» permalink