My Jekyll version is 3.8.6.
If I have too many elseif I get a for logic error where no for loop was written. If I remove one elseif, it works.
This does not work:
{% 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 %}
This Works!
{% 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 %}
The error I get with the additional elsif
is
Jekyll Feed: Generating feed for posts Liquid Exception: Liquid syntax error (/home/xxxxx/repositories/legal/_includes/_head.html line 100): 'for' tag was never closed included in /_layouts/default.html Error: Liquid syntax error (/home/xxxx/repositories/legal/_includes/_head.html line 100): 'for' tag was never closed included Error: Run jekyll build --trace for more information.
Line: 100 is {% elsif page.jsontype == "lawyer" %}
.
Edit 1:
I have got the same error when using 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 %}
It still shows the same error pointing to the end of the head file.
The file collectionJSONLD.html
was missing {% endfor %}
{% for member in site.data.members %}
{
"@type": "ListItem",
"name": "{{ member.name }}",
"url": "{{ member.permalink }}",
"position": "{{ forloop.index }}"
{% if forloop.first %}
},
{% elsif forloop.last %}
}
{% endif %}
{% endfor %}
],