Simple nested navigation I'm new to Craft CMS. I have the following single level navigation code:



&lt;ul&gt;
  &lt;li&gt;
    &lt;a href="/products" class="app-nav__primary"&gt;Products&lt;/a&gt;
    &lt;ul class="app-nav__secondary"&gt;
      {% for entry in craft.entries.section('products') %}
      &lt;li&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;
      &lt;/li&gt;
      {% endfor %}
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;




How would i adjust this to show a second level navigation in within the parent li? I'm looking for something like this:



&lt;ul&gt;
  &lt;li&gt;
    &lt;a href="/products" class="app-nav__primary"&gt;Products&lt;/a&gt;
    &lt;ul class="app-nav__secondary"&gt;
      {% for entry in craft.entries.section('products') %}
      &lt;li&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;
        if (child) { '
          &lt;li&gt;&lt;a href="child.link"&gt;child.title&lt;/a&gt;
        }
        &lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
    &lt;/li&gt;
&lt;/ul&gt;
You could use the children tag:

{% set entries = craft.entries.section('products') %}
&lt;ul&gt;
    &lt;li&gt;
        &lt;a href="/products" class="app-nav__primary"&gt;Products&lt;/a&gt;
        &lt;ul class="app-nav__secondary"&gt;
            {% nav entry in entries %}
                &lt;li&gt;
                    &lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;
                    {% ifchildren %}
                        &lt;ul&gt;
                            {% children %}
                        &lt;/ul&gt;
                    {% endifchildren %}
                &lt;/li&gt;
            {% endnav %}
        &lt;/ul&gt;
    &lt;/li&gt;
&lt;/ul&gt;