Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
desc 'Generate tags page'
task :tags do
puts "Generating tags..."
require 'rubygems'
require 'jekyll'
include Jekyll::Filters
options = Jekyll.configuration({})
site = Jekyll::Site.new(options)
site.read_posts('')
site.categories.sort.each do |category, posts|
html = ''
html << <<-HTML
---
layout: default
title: Postings tagged "#{category}"
---
<h1 id="#{category}">Postings tagged "#{category}"</h1>
html << '<ul class="posts">'
posts.each do |post|
post_data = post.to_liquid
html << <<-HTML
<li><a href="#{post.url}">#{post_data['title']}</a></li>
HTML
end
html << '</ul>'
File.open("tags/#{category}.html", 'w+') do |file|
file.puts html
end
end
puts 'Done.'
end
@jeffreycentex

This comment has been minimized.

Copy link

@jeffreycentex jeffreycentex commented May 26, 2014

You need an additional HTML command after line 18. Took a while for this Ruby absolute noobie to get that to work...

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