[英]Jekyll array contains check
我的_config.yaml中有一個數組。 讓我們說吧
exclude_pages: [ "/404.html", "/search.html", "/atom.xml", "/rss.xml", "/index.html", "/sitemap.txt" ]
我想要做的是在site.pages的頁面循環中排除這些頁面。 以下是我正在嘗試的代碼。
{% for entry in site.pages %}
{% if site.exclude_pages contains entry.url %}
<!-- Do Nothing -->
{% else %}
<!-- Show Page -->
{% endif %}
{% endfor %}
但不知怎的,它沒有發生。 此代碼中的所有頁面都被忽略。
知道我在這里缺少什么嗎?
試試:
exclude_pages: [ "index.html", "anyfolder/index.html" ]
然后使用entry.path
循環而不是entry.url
:
{% for entry in site.pages %}
{% if site.exclude_pages contains entry.path %}
<!-- Do Nothing -->
{% else %}
<!-- Show Page -->
{% endif %}
{% endfor %}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.