2015-02-24 119 views
0

當我在比較post.category是否有一個帖子時,該變量更多時,我把{{post.category}}它打印名稱。這就好像如果我在site.post.category中處理所有值的時候,他最不存在的話。問題是我想獲得當前的帖子來比較該類別。我想按類別列出帖子。Jekyll中的循環和變量如何?

<div class="posts"> 
     {% for post in site.posts %} 
     {% if post.category == Eventos %} 
     <hr> 
     <div class="post"> 
      <h1 class="post-title"> 
       <a href="{{ site.url }}{{post.url}}"> 
       {{ post.title }} 
       </a> 
      </h1> 
      <span class="post-date">{{ post.date | date_to_string }}/{{ post.category }}</span> {{ post.excerpt }} 
      <h6><a href="{{ site.url }}{{post.url}}">Leia mais...</a></h6> 
     </div> 

      {% endif %} 
     {% endfor %} 
    </div> 
+0

這是有點不清楚你問。 – nikaltipar 2015-02-24 14:38:08

+0

只需要過濾帖子的類別 – 2015-02-24 14:50:47

回答

0

試用類別

{% if post.categories | contains: 'Eventos' %} 
+0

感謝您的幫助,我設法用'{%if post.category =='Events'%}解決了' – 2015-02-25 12:28:12