Skip to content

Instantly share code, notes, and snippets.

Created July 9, 2009 11:02
Show Gist options
  • Save alexyoung/143571 to your computer and use it in GitHub Desktop.
Save alexyoung/143571 to your computer and use it in GitHub Desktop.
namespace :tags do
task :generate do
puts 'Generating tags...'
require 'rubygems'
require 'jekyll'
include Jekyll::Filters
options = Jekyll.configuration({})
site =
html =<<-HTML
layout: default
title: Tags
site.categories.sort.each do |category, posts|
html << <<-HTML
<h3 id="#{category}">#{category}</h3>
html << '<ul class="posts">'
posts.each do |post|
post_data = post.to_liquid
html << <<-HTML
<a href="#{post.url}">#{post_data['title']}</a>
html << '</ul>'
end'tags.html', 'w+') do |file|
file.puts html
puts 'Done.'
Copy link

@coolja86 - That's fantastic! I had something similar working before I upgraded to Jekyll 0.6.2, but something in one of the intervening versions messed up the site.tags hash. Your hackish array treatment works almost perfectly.

One question… have you figured out a way to sort the tags? I used to be able to use for tags in site.tags|sort and that was it, but it doesn't work anymore. Have you had any luck?


Copy link


I tried a few things, but I couldn't get it to work. Any progress?

Copy link

After trying to make some Liquid filters, I finally got it to work using a patch to the Jekyll core. If you add elstudio's patch (, it sorts the tags hash using RBTree (you'll have to install that gem). Your tags should be sorted without any modification to your code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment