Jekyll 类别导致 "if / then" 语句出现问题
Jekyll categories causing problems with "if / then" statements
我有一个 Jekyll post YAML Front Matter 像这样:
---
layout: post
title: "Insulation"
categories: build-manual
variable: build-manual // this is just for troubleshooting purposes
---
您会认为在 post 的页面上我可以使用当前 post 的类别编写一个简单的 liquid if / then 语句。像这样:
{% if page.categories == 'build-manual' %}
Hey I am in build-manual category
{% else %}
No I am not in build-manual category
{% endif %}
出于某种原因,这不起作用。我收到输出:"No I am not in build-manual category"
为了让它更混乱,如果我将 "page.categories" 更改为 "page.variable" 它会起作用。我收到输出:"Hey I am in build-manual category"
关于为什么它不能识别类别的任何想法?
这解决了问题:
{% if page.categories contains "build-manual" %}
{% endif %}
我有一个 Jekyll post YAML Front Matter 像这样:
---
layout: post
title: "Insulation"
categories: build-manual
variable: build-manual // this is just for troubleshooting purposes
---
您会认为在 post 的页面上我可以使用当前 post 的类别编写一个简单的 liquid if / then 语句。像这样:
{% if page.categories == 'build-manual' %}
Hey I am in build-manual category
{% else %}
No I am not in build-manual category
{% endif %}
出于某种原因,这不起作用。我收到输出:"No I am not in build-manual category"
为了让它更混乱,如果我将 "page.categories" 更改为 "page.variable" 它会起作用。我收到输出:"Hey I am in build-manual category"
关于为什么它不能识别类别的任何想法?
这解决了问题:
{% if page.categories contains "build-manual" %}
{% endif %}