Taxonomy based dynamic menu system

I’ve tried a couple of things, and I’m not sure what I’ve got so far is the best way to do this. I have a series of 5 categories, which correspond to a set of 5 top-level directories. These 5 categories make up the top level navigation.

Within these 5 directories are all of the pages that should be listed in the sub-nav when one of the categories is selected. So the structure is:
— html
├── pages
├── 01.category
├── 01.page
└── docs.md
├── 02.page
└── docs.md
└── category.md
├── 02.category
├── 01.page
└── docs.md
├── 02.page
└── docs.md
└── category.md

I'm using the sidebar code from the rtfm theme, and on the top-level it works great:

{% macro loop(page, parent_loop) %}
{% if parent_loop|length > 0 %}
{% set data_level = parent_loop %}
{% else %}
{% set data_level = 0 %}
{% endif %}

{% for p in page.children.visible %}
{% set parent_page = p.activeChild ? ’ parent’ : ‘’ %}
{% set current_page = p.active ? ’ active’ : ‘’ %}


  • {% if p.children.count > 0 %}
    {{ p.menu }}

      {{ _self.loop(p, parent_loop+loop.index) }}

    {% else %}
    {{ p.menu }}
    {% endif %}

  • {% endfor %}
    {% endmacro %}

    {% macro version§ %}
    {% set parent_page = p.activeChild ? ’ parent’ : ‘’ %}
    {% set current_page = p.active ? ’ active’ : ‘’ %}

    {% if p.activeChild or p.active %} {% else %} {% endif %} {{ p.menu }}
    {% endmacro %}

    {% if theme_config.top_level_version %}
    {% for slug, ver in pages.children %}
    {{ _self.version(ver) }}


      {{ _self.loop(ver, ‘’) }}

    {% endfor %}
    {% else %}
      {{ _self.loop(pages, '') }}
    {% endif %} ```

    once you click on any of the pages the parent_loop gets refreshed, and the menu changes. I’d like it to be more or less static once it’s built after selecting one of the categories. And right now, I’m drawing a blank.

    Here’s a screenshot as well. Top-level-category

    What is the benefit of using taxonomy based navigation? I think what you are wanting to do would be better served by just creating those category folders with your top-level categories and then subfolders representing sub-categories etc.

    Basically recreate your folder structure as your category structure? This would work with the default menu code as-is.