2016-04-26 44 views
0

我有一個頁面顯示按標籤排序的所有帖子。問題是我只想要顯示一些標籤,而不是全部。事情將會在「for site in tag.tags」實現一個if like標籤== x之後。我是新來的哲基爾和紅寶石,我不知道如何做到這一點:/在jekyll標籤頁中執行if

{% capture site_tags %}{% for tag in site.tags %}{{tag | first }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %} 


{% assign tag_words = site_tags | split:',' | sort %} 


<ul class="tags"> 
{% for item in (0..site.tags.size) %}{% unless forloop.last %} 
{% capture this_word %}{{ tag_words[item] }}{% endcapture %} 
<li> 
<a href="#{{ this_word | cgi_escape }}" class="tag">{{ this_word }} 
<span>({{ site.tags[this_word].size }})</span> 
</a> 
</li> 
{% endunless %}{% endfor %} 
</ul> 

<div> 
{% for item in (0..site.tags.size) %}{% unless forloop.last %} 
{% capture this_word %}{{ tag_words[item] }}{% endcapture %} 
<h2 id="{{ this_word | cgi_escape }}">{{ this_word }}</h2> 
{% for post in site.tags[this_word] %}{% if post.title != null %} 
<div> 
<span style="float: left;"> 
<a href="{{ post.url }}">{{ post.title }}</a> 
</span> 
<span style="float: right;"> 
{{ post.date | date_to_string }} 
</span> 
</div> 
<div style="clear: both;"></div> 
{% endif %}{% endfor %} 
{% endunless %}{% endfor %} 
</div> 

回答

0

更改此:

{% capture site_tags %} 
    {% for tag in site.tags %}...{% endfor %} 
{% endcapture %} 

進入這個:

{% capture site_tags %} 
    {% for tag in site.tags %} 
    {% if tag.title != 'excludedtag' %}...{% endif %} 
    {% endfor %} 
{% endcapture %} 

而變「 excludedtag「添加到要排除的標記標題。