Skip to main content

Module breadcrumbs

Module breadcrumbs 

Source
Expand description

Breadcrumb engine — walks the page tree once and returns an ordered list of (title, url, is_current) crumbs.

Powers both public templates (via to_context_value) and the admin chrome (admin handlers can call resolve_breadcrumbs directly and stuff the result into Tera context). The shared _breadcrumbs.html macro in crate::admin::register_templates renders the standard <nav aria-label="Breadcrumb"> shape plus a parallel JSON-LD BreadcrumbList block for SEO.

§Public-side example

{# In a Tera template: #}
{% set crumbs = breadcrumbs(page_id=page.id) %}
{% import "_breadcrumbs.html" as bc %}
{{ bc::render(crumbs=crumbs) | safe }}

§Options

  • include_root — keep the tenant root crumb (defaults true).
  • include_current — keep the leaf crumb (defaults true; public templates usually want this off when the breadcrumb sits right above the page’s <h1>).
  • max_depth — cap the walk to N ancestors; oversized trees degrade gracefully.

Structs§

BreadcrumbsOptions
Options controlling resolve_breadcrumbs.
Crumb
One link in the breadcrumb trail.

Functions§

resolve_breadcrumbs
Walk the page’s ancestor chain and return an ordered crumb list from root to leaf.
to_context_value
Convenience: render the breadcrumb crumb list as a JSON value suitable for stuffing into a Tera context. Use this in admin or public-render handlers right before calling tera.render(...):