Core Concepts
Navigation separates menu configuration (how deep a menu can nest, its cache TTL, edit permission, and custom node fields) from menu items (the hierarchical tree of links and passive elements managed by editors).
Architecture & Data Flow
Section titled “Architecture & Data Flow”flowchart LR
Schema["Menu Schemas\nsite/navigation/*.yaml + DB\n(yaml | db | hybrid)"] --> Registry["MenuRegistry"]
Registry --> Entries["Entries Storage\nnavigation-menus & navigation-node-{handle}"]
Entries --> Builder["TreeBuilder + Target Adapters\npage · url · entry · children · passive"]
Builder --> Cache["Two-Tier Cache\nIn-Memory + WireCache"]
Cache --> Render["MarkupNavigation HTML\n& BreadcrumbList JSON-LD"]
Cache --> Headless["Headless REST API\n/api/v1/navigation/*"]
Dual-Source Menu Schemas (yaml, db, hybrid)
Section titled “Dual-Source Menu Schemas (yaml, db, hybrid)”MenuRegistry discovers menus from two sources and records each menu’s active $source:
yaml: Defined as a file insite/navigation/{handle}.yaml(or an extra path registered via$navigation->addPath()). Ideal for version-controlled menus with custom nodefields:.db: Created inside Setup -> Navigation -> New Menu (navigation-menusEntries collection) or viamake:navigation --db. Ideal for client-managed landing-page or seasonal menus.hybrid: A YAML-defined menu whose title, description, depth, cache TTL, or permission was overridden in the database while preserving its YAML customfields:.
Entries-Backed Storage & 10-Level Nesting
Section titled “Entries-Backed Storage & 10-Level Nesting”Navigation creates zero custom SQL tables. Instead, NavigationBlueprints registers hidden Entries collections (revisions: 10, sluggable: false):
navigation-menus: Stores database-backed menus and YAML menu overrides.navigation-nodes: Default collection for menus without custom fields.navigation-node-{handle}: Per-menu node blueprint generated automatically whenever a YAML menu defines customfields:(for example,navigation-node-mainwithsubtitleandbadge_text).
Because Entries caps native entries_items.parent_id nesting at 2 levels on collections, Navigation tracks arbitrary tree depth (up to maxDepth: 10) using an indexed parent_node_id UUID string and node_depth integer maintained transactionally by NodeHierarchyManager.
Immutable Value Objects
Section titled “Immutable Value Objects”When you query $navigation->tree('main') or $navigation->breadcrumbs($page), Navigation returns strongly typed, readonly value objects:
MenuDefinition:$handle,$title,$description,$icon,$maxDepth,$cacheTtl,$includeHiddenPages,$permission,$fields,$source,$hasInvalidPermission.NavigationTree: Holds$menuplusnodes(),flatten(),findById(),findByPage(),activeNode(),activeTrail(),isEmpty(),count(),totalCount(), andtoPublicArray().NavigationNode: Holds$id,$type,$title,$description,$panelHandle,$icon,$url,$depth,$sort,$openNewTab,$isExternal,$isPassive,$passiveKind,$itemClasses,$linkClasses,$attributes,$visible, pluschildren(),parent(),ancestors(),isActive(),isActiveTrail(),iconSvg(), andgetCustom().NavigationBreadcrumbs&BreadcrumbItem: Holds ordered trail items withtoArray()andtoSchemaOrg()(BreadcrumbList).
Automatic Two-Tier Caching & Invalidation
Section titled “Automatic Two-Tier Caching & Invalidation”NavigationTreeCache caches resolved trees in memory (per request) and in WireCache (Navigation::CACHE_NAMESPACE = 'navigation') for each menu’s cacheTtl (default 3600 seconds). PageSyncManager listens to ProcessWire Pages::* and Entries::* save, move, publish, trash, and delete hooks, calling invalidateForPage() and invalidateForEntry() automatically so menus never display stale titles, moved URLs, or unpublished pages.