Search code examples
middleman

Using Middleman Tags


I am wondering if someone could explain how I can utilise tags in an article.

The documentation states that by default the blog extension should allow you to access tagged articles via tags/blogging.html. http://middlemanapp.com/guides/blog I guess I'm not sure if I need to create this dir (tags/blogging.html) or if its generated for me?

Then I'm wondering how to create a list of tags, each with a URL that points to this tag template.

I've added this example tag data to the front matter of a few of my articles.

--- 
title: My Middleman Blog Post
date: 2011/10/18
category: music
tags: blogging, middleman, hello, world
---

my index.html.erb looks like this:

<section class="article-index music">
    <% data.blog.articles.each_with_index do |article, i| %>
        <% if article.category == 'music' %>
            <article>
            <h2><a href="<%= article.url.sub('.html','') %>"><%= article.title %></a></h2>
            <time pubdate><%= article.date.strftime('%b %e') %></time>
            <span class="categories"><%= article.tags %></span>
            <%= article.summary %>
            </article>
        <% end %>
    <% end %>
</section>

This is outputting all my articles, with a title, date, all tags and a summary.

I'm assuming you need to loop through all the tags and output each in a URL of its own, but I'm not really sure of the best way to do this.

At a guess I'm assuming its something like:

<% article.tags.each do |tag| %>
    <a href="/tags/#{tag}.html">tag</a>
<% end %>

Any help is appreciated. Thanks


Solution

  • Not supported in 2.0. Possibly in upcoming 3.0