Moving from WordPress to Middleman, Part II: Mulitple categories per post

One oddity of Middleman and its blog template is that its model for additional metadata is a bit weak. The documentation tells us that you can have "Custom Article Collections." The example they give is for a "category" but you can really only have one value per category attribute. In other words, you can't have multiple categories separated with a comma, which is the pattern for tags. My old WordPress blog had multiple categories per post, with nice pages listing all posts by a given category. I'd like to keep those pages working. But without a strategy for multiple categories per post, I can't refresh my old blog as I'd like.

So how to fix this? It would be possible to create an extension that imitates the "tag" support, but the class organization looks fairly complicated, and I'm not sanguine about writing an extension only to see that the class structure changes and my code starts to fail.

Another way to do this is with global helper methods. This has the downside of polluting the global space. But it has the benefit of being obvious. So here's what I did.

First I created a sample blog with a couple of articles.

middleman init middleman-with-multiple-categories-per-post --template=blog
cd middleman-with-multiple-categories-per-post
middleman article '"Going to Boston by plane"'
middleman article '"Going to Chicago by train"'

In this case, I want both articles to be in the category "Travel" while the Boston trip is also in the category "Boston" and the Chicago trip...

Read more and comment . . .