Page navigation

Outputting a site navigation using the configuration set within the Site Builder

Multi-level navigation

The below example outputs a multilevel navigation meant to be used for a dropdown menu. It contains logic to add classes to elements based on if the nav item has children or if the current page the user is on matches the nav item.

<ul class="nav navbar-nav navbar-right">
{% for item in linklists.mainmenu recursive -%}
<li class="{%- if item.children %}dropdown{% endif %}{% if page.path == %} active{% endif %}{% for sub_item in item.children %}{% if page.path == %} active{% endif %}{% endfor %}">
  {%- if item.children %}
    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{|safe }} <span class="caret"></span></a>
    <ul class="dropdown-menu">
      {% for sub_item in item.children %}
        <li><a href="{{ }}">{{|safe }}</a></li>
      {% endfor %}
  {% else %}
    <a href="{{ }}">{{|safe }}</a>
  {% endif %}
{%- endfor -%}

Last updated