简体   繁体   中英

liquid syntax error … unknown tag elsif

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM