Skip to content

Instantly share code, notes, and snippets.

@technosophos
Created March 12, 2014 14:38
Show Gist options
  • Select an option

  • Save technosophos/9508249 to your computer and use it in GitHub Desktop.

Select an option

Save technosophos/9508249 to your computer and use it in GitHub Desktop.
Jekyll Category Listing Plugin
module Jekyll
class CategoryListTag < Liquid::Tag
# safe true
def initialize(tag_name, text, tokens)
super
end
def render(context)
html = ""
categories = context.registers[:site].categories
categories.each do |cat, posts|
html << "<a href='/category/#{cat}/' class='radius label label-default'>#{cat}</a> "
end
html
end
end
end
Liquid::Template.register_tag('category_list', Jekyll::CategoryListTag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment