Blogging, categories & pagination

I’ve been trying to get to grips with the Middleman blog extension and have come up with the idea of using it to split posts into either journal entries or full blown tutorials/essays.

I have two templates set up with the following code to check if a blog post has the ‘essay’ tag and either display it in the /essays page or the /journal page.

The logic looks like this for the essay page:

- page_articles.select { |a| a.tags.include? 'essay' }.each_with_index do |article, i|

and this for the journal:

- page_articles.each_with_index do |article, i|
  - unless article.tags.include?("essay")

The problem is is that this messes with pagination. The pagination is calculated based on the total number of posts, even if they aren’t included in the page. This is ending up with me having the essays section listing maybe one thing before it generates pagination to go on.

I’m pretty much a ruby neophyte, so I haven’t managed to work out a way of making pagination work happily with this splitting of entries.

Is there some way I can stop having irregular amounts of posts on their respective pages or is this just me trying to push the blogging extension too far?

Middleman Blog already has “tag” support. Use the taglink option to control where they are placed. The default is:

activate :blog do |b|
  b.taglink = "tags/:tag.html"
end

You’ll also need to specify which template file handles tag index pages:

activate :blog do |b|
  b.taglink = "tags/:tag.html"
  b.tag_template = "tags_list.html"
end

See more in the docs: http://middlemanapp.com/blogging/#toc_6

Gah, spent too much time trying to be too clever it seems and failed to notice the completely obvious.

Is there a way to add an extra route to allow for something like http://sitename/essays to proxy to http://sitename/journal/tags/essays?

I’ve tried to go through the docs but everything seems to relate to dynamic pages.

I don’t think so. Setting that taglink to the root would probably cause a bunch of problems. You could use a redirect.

redirect "/essays/index.html", :to => "/journal/tags/essays"