[Middleman] Create a list of articles for each tag

Created on November 30, 2026

With middleman-blog enabled, configure the tag URL pattern and the template in config.rb. For example, articles tagged ruby or middleman produce tags/ruby.html and tags/middleman.html.

activate :blog do |blog|
  blog.sources = "articles/{title}.html"
  blog.permalink = "articles/{title}.html"
  blog.taglink = "tags/{tag}.html"
  blog.tag_template = "tags.html"
end

Create the template as source/tags.html.erb. The build requires the file referenced by tag_template. In the template, tagname is the current tag and article.tags lists the tags attached to an article.

<% blog.articles.each do |article| %>
  <% if article.tags.include?(tagname) %>
  <div class="article"><a href="<%= article.url %>"><%= article.title %></a></div>
  <% end %>
<% end %>
middleman