pyssg is pre-1.0 and under active development - APIs, config, and themes may change.
pyssg.plugins.nav

1 min read

pyssg.plugins.nav

Navigation plugin.

Builds site-wide navigation data during evaluate_collections and stashes it on build.site_data for templates (via the render context): a section-grouped menu (sidebar), a url_titles map (breadcrumbs), and an ordered_pages list (prev/next).

This is the "fan-out" feature: nav appears on every page. Correctness under incremental builds is guaranteed by the engine's render sweep -- a structural change (add/move/delete a doc) changes the menu, so every page's rendered HTML differs and is re-emitted; a body-only edit leaves the menu identical, so other pages hit the render cache and are not re-emitted.

build_navigation(build: Build) -> None

Populate build.site_data with menu / url_titles / ordered_pages.

Navigation is grouped per locale: each menu section carries a locale tag and is keyed by (locale, section), and ordered_pages keeps every locale's pages contiguous so prev/next never crosses languages. A single-locale (or no-i18n) site has every locale equal to "", which reduces to the plain alphabetical-by-section menu and a flat ordered list.

class NavigationPlugin

Computes navigation data each build.

Factory used in pyssg.config.py.