Generate a flat navigation using the default page array.
{% raw %}{{ pages | navigation }}{% endraw %}
Generate a nested navigation using the nested array.
{% raw %}{{ nested_pages | navigation }}{% endraw %}
The html structure and the css classes allows styling current page, active parent pages, naked directories, getting pages by name, etc. to build any type of navigation : dropdown menus, single-lined breadcrumbs...
{% raw %}.is-page, .is-directory, .is-current, .is-active, .has-childs ...{% endraw %}
Filtering pages paths with the exclude filter :
{% raw %}{{ nested_pages | exclude('PicoPagesList') | navigation }}{% endraw %}
Filter the inner pages by using a trailing slash :
{% raw %}{{ nested_pages | exclude('PicoPagesList/') | navigation }}{% endraw %}
Filter all pages except the given ones with only, and chain filters :
{% raw %}{{ nested_pages | only('PicoPagesList') | exclude('PicoPagesList/sub/bar') | navigation }}{% endraw %}
Filters can be given multiple paths :
{% raw %}{{ nested_pages | only('PicoPagesList/sub', 'index') | navigation }}{% endraw %}
Custom loop :
{% raw %}{% macro menu(items) %}
<ul>
{% for name,item in items %}
<li>
{% if item.url %}
<a href="{{ item.url }}">{{ item.title }}</a> : {{ item.description }}
{% else %}
<span>{{ name }}</span>
{% endif %}
{% if item._childs %}
{% import 'macros.twig' as macros %}
{{ macros.menu(item._childs) }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endmacro %}{% endraw %}
{% raw %}{% import 'macros.twig' as macros %}
{{ macros.menu(nested_pages) }}{% endraw %}