79639456

Date: 2025-05-26 19:07:41
Score: 1.5
Natty:
Report link

I know this is an old question, but I stumbled upon this looking for how to do this myself and it took some effort to finally figure it out.

It depends on the amount of nesting you have, but here is how you do it for a top-level page (say, section header):

{% macro list_pages_l1(page_title, navigation) -%}
    {% for nav1 in navigation %}
        {% if nav1.title == page_title %}
            {% for child in nav1.children %}
                {% if child.title != page_title %}
- [{{ child.title }}]( {{ child.canonical_url }} )
                {% endif %}
            {% endfor %}
        {% endif %}
    {% endfor %}
{%- endmacro %}

You can save this in a file (say macros.md) and then call this function from any page, like so:

{% from 'macros.md' import list_pages_l1 %}
{{ list_pages_l1('Plugins', navigation) }}

If interested, you can find my full implementation on GitHub. (permalink). I have also built a L2 implementation which is useful for nested pages.

P.S. Special thanks to @fralau for providing the initial guidance and actually building this amazing library.

Reasons:
  • Blacklisted phrase (0.5): thanks
  • Contains signature (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @fralau
  • Low reputation (0.5):
Posted by: Yashovardhan99