Skip to content

Nested recursive sections in nav bar

This merge request introduces nested recursive subsections in the navigation bar.

This is an adaption from this implementation for nested menus in Hugo. After I had implemented this for the Apertis website, build times drastically increased (from seconds to minutes).

I finally decided to build the navigation bar list only once, and use javascript to control the expansion of sections and pages. This seems to keep build times acceptable, while retaining the functionality of the original implementation.

An important change is, that subsection directories (e.g. "my_subsection") now require an accompanying markdown page (i.e. "my_subsection.md"). This had to be included for the Releases section and therefore is also part of this merge request. Index pages whose filename is name "_index.md" should only be used on the top level (currently each top section has an index page), not in subsections.

A preview is available here: https://sietze.vanbuuren.pages.apertis.org/apertis-website-nested-menus/release/

Feature summary:

  • complete nav menu tree is generated using hugo templates/partials
  • inactive subsections are hidden by default
  • javascript is used to expand and highlight sections for current page
  • subsection folders should not contains an _index.md
  • instead subsection require an md file with the same name
  • i.e. subsection directory "subsection" is accompanied by "subsection.md"

Signed-off-by: Sietze van Buuren Sietze.vanBuuren@de.bosch.com

Edited by Sietze van Buuren

Merge request reports