I’ve taken the plunge to a static-HTML blog with Jekyll. I’m impressed so far. I love having the whole she-bang in git, but then again the whole idea of a datastore in git has fascinated me from the start.
And pushing to GitHub pages (willcodeforfoo.github.com) just worked. A few minutes after pushing, I hit the URL. Half expecting an error page and half expecting just nothing I found the site. Just the way I hoped it would work.
I thought I’d share some of the things I encountered along the way to help folks just getting started.
Source Code
First up, feel free to check out the full source code that Jekyll uses to build all this html: http://github.com/willcodeforfoo/willcodeforfoo.github.com/tree/master
Importing from Mephisto
Here’s a hacky, super-simple, one-liner script that I threw together at the Mephisto Rails console:
Content.find_by_sql("SELECT id, permalink, body, published_at, title FROM contents WHERE type = 'Article' AND published_at IS NOT NULL ORDER BY published_at").each {|c| File.open("#{c.published_at.strftime('%Y-%m-%d')}-#{c.permalink}.textile", "w+"){|f| f.puts "---\nlayout: post\ntitle: #{c.title}\n---\n\n"; f.puts c.body }}
This will not work 100%, though. It doesn’t do anything fancy like output real YAML, with escaped characters. So if you have funky characters in your titles, things could blow up.
uninitialized constant Classifier::LSI::Matrix (NameError) when running with --lsi option
Applying this patch to Classifier’s lsi.rb file seemed to do the trick.
As an aside: I’m truly impressed with the Classifier gem. I’ve seen its Bayesian stuff before, but Jekyll was my first exposure to LSI.
Categories
I was thinking about adding other “types” of posts to my site, something along the lines of books I’m reading, music I’m enjoying, etc.
I decided I could use Categories to pull this off, so my structure looks something like this:
|-- CNAME
|-- _layouts
| |-- book.html
| |-- master.html
| |-- music.html
| `-- post.html
|-- about.textile
|-- articles
| `-- _posts
| |-- 2009-02-10-reducing-the-noise.textile
| `-- 2009-02-12-jekyll.textile
|-- atom.xml
|-- books
| `-- _posts
| `-- 2009-02-12-click.textile
|-- images
| `-- feed.png
|-- index.html
|-- movies
| `-- _posts
|-- music
| `-- _posts
| `-- 2009-02-12-ray-lamontagne-gossip-in-the-grain.textile
`-- stylesheets
`-- styles.css
Then on my homepage, for example, I can pull all the music entries with album art from Amazon by doing:
{ % for music in site.categories.music % }
<a href=""><img alt="" src="http://ec1.images-amazon.com/images/P/.01.MZZZZZZZ.jpg"></a>
{ % endfor % }
(I added an asin key to the post’s metadata header.) Slick!
Excerpts
Thankfully thanks to Jekyll’s slick metadata feature for posts, all I had to do was add a excerpt key to the header of a post and throw my excerpt there:
---
layout: post
title: Jekyll
excerpt: |-
I've taken the plunge to a static-HTML blog with Jekyll. I'm impressed so far. I love having the whole she-bang in git, but then again the whole idea of a "datastore in git":/2008/04/13/git-as-a-data-store.html has fascinated me from the start.
And pushing to GitHub pages (willcodeforfoo.github.com) just _worked_. A few minutes after pushing, I hit the URL. Half expecting an error page and half expecting just nothing I found the site. Just the way I hoped it would work.
Big ups to "Michael Bleigh":http://mbleigh.com for making his whole blog available on "GitHub":http://github.com/mbleigh/mbleigh.github.com/tree/master. I didn't take much design-wise, but seeing how things were structured was a huge help. I did nick his Atom feed template.
---
h3. Importing from Mephisto
Here's a hacky, super-simple, one-liner script that I threw together at the Mephisto Rails console:
The next gotcha was that I couldn’t get Jekyll to Textilize anything other than the content, and since my excerpt needed to be rendered as Textile, this was a problem.
So I submitted a patch that creates a filter called textilize that I can pass my excerpt into for formatting. Hopefully it gets applied to the master branch that GitHub Pages uses.
Inspiration
Big ups to Tom Preston-Werner for writing Jekyll and Michael Bleigh for making his whole blog’s source available on GitHub. I didn’t take much design-wise, but seeing how things were structured was a huge help. (I did nick his Atom feed template.)