在链接的答案中,没有其他块,也没有输出,它只生成commonTag。
{% for tag in post.tags %}
{% comment %}---> Only compare if post is
not same as current page {% endcomment %}
{% if post.url != page.url %}
{% if page.tags contains tag %}
{% assign sameTagCount = sameTagCount | plus: 1 %}
{% capture tagmarkup %} <span class="label label-default">{{ tag }}</span> {% endcapture %}
{% assign commonTags = commonTags | append: tagmarkup %}
{% endif %}
{% endif %}
{% endfor %}
然后,如果sameTagCount大于或等于minCommonTags,它会输出一个链接h5。
{% if sameTagCount >= minCommonTags %}
<div>
<h5><a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}{{ commonTags }}</a></h5>
</div>
...
在你的例子中,t输出“没有相关帖子”如果条件
{% if page.tags contains tag %}
事实并非如此,这显然发生了三次。