# Navigation Functions URL: /bengal/docs/0.5.1/reference/template-functions/navigation-functions/ Section: template-functions Tags: reference, functions, navigation, sections -------------------------------------------------------------------------------- Navigation Functions These global functions simplify common navigation patterns. get_section Get a section by its path. Cleaner alternative to site.get_section_by_path(). {% let docs = get_section('docs') %} {% if docs %} <h2>{{ docs.title }}</h2> {% for page in docs.pages |> sort_by('weight') %} <a href="{{ page.href }}">{{ page.title }}</a> {% end %} {% end %} section_pages Get pages from a section directly. Combines get_section() with .pages access. {# Non-recursive (direct children only) #} {% for page in section_pages('docs') |> sort_by('weight') %} <a href="{{ page.href }}">{{ page.title }}</a> {% end %} {# Recursive (include all nested pages) #} {% for page in section_pages('docs', recursive=true) %} <a href="{{ page.href }}">{{ page.title }}</a> {% end %} page_exists Check if a page exists without loading it. More efficient than get_page() for conditional rendering. {% if page_exists('guides/advanced') %} <a href="/guides/advanced/">Advanced Guide Available</a> {% end %} {# Works with or without .md extension #} {% if page_exists('docs/getting-started.md') %}...{% end %} {% if page_exists('docs/getting-started') %}...{% end %} get_page Retrieve a page object by path. Similar to doc() but intended for programmatic page access. {% let page = get_page('docs/getting-started') %} {% if page %} <a href="{{ page.href }}">{{ page.title }}</a> {% end %} {# Works with various path formats #} {% let p1 = get_page('docs/api.md') %} {# With extension #} {% let p2 = get_page('docs/api') %} {# Without extension #} {% let p3 = get_page('/docs/api/') %} {# Absolute path #} Parameters: path: Page path (with or without .md extension) Returns: Page object or None Use cases: Track/series navigation Related pages lookup Dynamic content inclusion Results are cached per-render for performance. -------------------------------------------------------------------------------- Metadata: - Author: lbliii - Word Count: 260 - Reading Time: 1 minutes