How I Organize Posts In Jekyll

Since November 2010, I have been running Jekyll to power this blog. Before Jekyll, I was on self-hosted Wordpress, which could explain some of my decisions around how I organize my posts because I didn’t want to break any existing links.

You can find some interesting resources on Jekyll that I collected while building this site at http://www.delicious.com/dsamovskiy/jekyll.

If you are reading this post via RSS, you can find all code snippets below at https://gist.github.com/852008 or open this post in a browser. As of the time of this writing, I use Jekyll 0.7.0.

Categories

I define categories for each post in its YAML Front Matter.

My category layout uses category_name as parameter which I can access as page.category_name. For example, all posts in current category are going to be in site.categories.[page.category_name].

And here is a plugin that I use to generate each category’s main page from an empty one called “category.html” (instead of explicitly having a separate page for each category):

Post Counts by Category

In my templates I use site.sorted_categories as a list of categories sorted by the number of posts in each category in descending order:

And here is a plugin that I use to build this list:

Related Posts

For each post I build a list of related posts as N most recent posts in the same categories. Here is how I populate post.related:

Categories: ruby | blogging |