我想知道如果有人可以解釋如何在文章中使用標籤。使用中間人標籤
該文檔指出,默認情況下,博客擴展應允許您通過tags/blogging.html訪問標籤文章。 http://middlemanapp.com/guides/blog 我想我不確定是否需要創建這個dir(tags/blogging.html)或者它是否爲我生成?
然後我想知道如何創建一個標籤列表,每個標籤都有一個指向這個標籤模板的URL。
我已經將這個示例標籤數據添加到我的一些文章的前端。
---
title: My Middleman Blog Post
date: 2011/10/18
category: music
tags: blogging, middleman, hello, world
---
我index.html.erb看起來是這樣的:
<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>
這是我輸出的所有文章,有標題,日期,所有的標籤和摘要。
我假設你需要遍歷所有的標籤,並輸出每個URL在它自己的URL,但我不確定最好的方式來做到這一點。
在猜測我假設它是這樣的:
<% article.tags.each do |tag| %>
<a href="/tags/#{tag}.html">tag</a>
<% end %>
任何幫助表示讚賞。 謝謝