我的 Jekyll 版本是 3.8.6。
如果我有太多 elseif 我得到一个 for 逻辑错误,其中没有编写 for 循环。如果我删除一个 elseif,它会起作用。
这不起作用:
{% if page.jsontype == "page" %}
{% include pageJSONLD.html %}
{% elsif page.jsontype == "collection" %}
{% include collectionJSONLD.html %}
{% elsif page.jsontype == "post" %}
{% include postJSONLD.html %}
{% elsif page.jsontype == "about" %}
{% include aboutJSONLD.html %}
{% elsif page.jsontype == "lawyer" %}
{% include lawyerJSONLD.html %}
{% elsif page.jsontype == "contact" %}
{% include contactJSONLD.html %}
{% else %}
{% include homeJSONLD.html %}
{% endif %}
这有效!
{% if page.jsontype == "page" %}
{% include pageJSONLD.html %}
{% elsif page.jsontype == "post" %}
{% include postJSONLD.html %}
{% elsif page.jsontype == "about" %}
{% include aboutJSONLD.html %}
{% elsif page.jsontype == "lawyer" %}
{% include lawyerJSONLD.html %}
{% elsif page.jsontype == "contact" %}
{% include contactJSONLD.html %}
{% else %}
{% include homeJSONLD.html %}
{% endif %}
我得到的附加错误elsif
是
Jekyll 提要:为帖子生成提要 Liquid 异常:Liquid 语法错误(/home/xxxxx/repositories/legal/_includes/_head.html 第 100 行):“for”标签从未关闭包含在 /_layouts/default.html 中错误:Liquid语法错误(/home/xxxx/repositories/legal/_includes/_head.html 第 100 行):“for”标签从未关闭包含错误:运行 jekyll build --trace 以获取更多信息。
线: 100 是{% elsif page.jsontype == "lawyer" %}
.
编辑1:
我在使用 case/when 时遇到了同样的错误
{% case page.jsontype %}
{% when 'page' %}
{% include pageJSONLD.html %}
{% when 'collection' %}
{% include collectionJSONLD.html %}
{% when 'post' %}
{% include postJSONLD.html %}
{% when 'about' %}
{% include aboutJSONLD.html %}
{% when 'lawyer' %}
{% include lawyerJSONLD.html %}
{% when 'contact' %}
{% include contactJSONLD.html %}
{% else %}
{% include homeJSONLD.html %}
{% endcase %}
它仍然显示指向头文件末尾的相同错误。