Reputation: 41
I am trying to create a nav for my jekyll / GitHub Pages site ... I have the following code for my nav ...
<nav>
<ul>
{% for nav in site.data.nav %}
(% if nav.subcategories != null %)
<li>
<a href="{{ site.url}}{{ nav.url}}">{{ nav.title }} &x25BC;</a>
<ul>
{% for subcategory in nav.subcategories %}
<li><a href="{{ site.url }}{{ subcategory.subhref }}">{{ subcategory.subtitle }}</a></li>
{% endfor %}
</ul>
</li>
{% elsif nav.title == page.title %}
<li class="active"><a href="{{ nav.url }}">{{ nav.title }}</a></li>
{% else %}
<li><a href="{{ site.url }}{{ nav.href }}">{{ nav.title }}</a></li>
{% endif %}
{% endfor %}
</ul>
</nav>
When I run the jekyll server I get the following error: Liquid syntax error (line 14): Unknown tag 'elsif'.
I have googled for several hours and every tutorial I've found says the elsif is a legitimate liquid tag.
Thank you to anyone you might be able to help!
Upvotes: 1
Views: 3102
Reputation: 3730
On line 4, you use parentheses instead of braces (curly brackets):
(% if nav.subcategories != null %)
should be:
{% if nav.subcategories != nil %}
Also, depending on your liquid environment, check for the falsy equivalent of an empty array. In Shopify you can use empty
instead of nil
or []
in jekyll.
Upvotes: 2