---
title: "Rendering menus in TYPO3"
manual: "Site Package Tutorial"
version: "main"
permalink: "https://docs.typo3.org/permalink/t3sitepackage:menu@main"
source: "Menu/Index.rst"
rendered: "2026-09-24T15:01:46+00:00"
---

# Rendering menus in TYPO3 {#menu}

There are several strategies to display menus or other navigation elements like
breadcrumbs and sitemaps in TYPO3.

-   [Menus as content elements](https://docs.typo3.org/permalink/t3sitepackage:menus-as-content-elements@main)
-   [Menus within the page view](https://docs.typo3.org/permalink/t3sitepackage:menus-within-the-page-view@main)
-   [TypoScript configuration of the main menu](https://docs.typo3.org/permalink/t3sitepackage:typoscript-configuration-of-the-main-menu@main)
-   [Fluid partial of the main menu](https://docs.typo3.org/permalink/t3sitepackage:fluid-partial-of-the-main-menu@main)
-   [Preview the page and use the menu](https://docs.typo3.org/permalink/t3sitepackage:preview-the-page-and-use-the-menu@main)
-   [Different menu types](https://docs.typo3.org/permalink/t3sitepackage:different-menu-types@main)

## Menus as content elements {#menu-content-element}

You can use a content element to display a menu. In the example data "Page 1"
contains a menu of subpages and page "Sitemap" a sitemap content element.

To adjust the templates of these content elements refer to chapter
[Overriding the default templates of content elements](https://docs.typo3.org/permalink/t3sitepackage:content-element-rendering@main).

## Menus within the page view {#menu-page-view}

A data processor (see also [dataProcessing](https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/DataProcessing/Index.html#dataProcessing)) can be
used to provide the data for one or several menus.

For menus usually the [menu data processor](https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/DataProcessing/MenuProcessor/Index.html#MenuProcessor),
which is provided by the TYPO3 Core, is used.

> [!TIP]
> Some extensions like [`b13/menus`](https://packagist.org/packages/b13/menus) offer performant menus for
> large sites or like [`georgringer/news`](https://packagist.org/packages/georgringer/news) menus for special purposes.

## TypoScript configuration of the main menu {#add-menu-processor}

We use TypoScript to configure these menus. The main menu is configured like this:

**packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/menu.typoscript**

```typoscript
page {
    10 {
        dataProcessing {
            20 = menu
        }
    }
}

```

This menu defines that the variable with the default name `menu` should contain
the information about the complete page tree of the current page.

System folders like the "Footer menu" from your example data, special page types
and pages excluded from the navigation are excluded.

A complete reference of this menu can be found in the TypoScript Reference:
[menu data processor](https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/DataProcessing/MenuProcessor/Index.html#MenuProcessor).

## Fluid partial of the main menu {#fluid-implement-main-menu}

In `packages/my_site_package/Resources/Private/Templates/Partials/Navigation/Menu.fluid.html`
you can find the partial that renders the main menu.

A menu usually contains several menu entries. We use the
[f:for ViewHelper](https://docs.typo3.org/other/typo3/view-helper-reference/main/en-us/Global/For.html#typo3fluid-fluid-for) to iterate over
all menu entries
and render them in turn:

**packages/my_site_package/Resources/Private/Templates/Partials/Navigation/Menu.fluid.html**

```html
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
    <f:for each="{menu}" as="menuItem">
        <li class="nav-item">
            <a class="nav-link {f:if(condition: menuItem.active, then:'active')}"
               href="{menuItem.link}"
               target="{menuItem.target}"
               title="{menuItem.title}"
            >
                {menuItem.title}
            </a>
        </li>
    </f:for>
</ul>

```

In each loop the current menu item is stored in variable `{menuItem}`.

You can use the [f:debug ViewHelper](https://docs.typo3.org/other/typo3/view-helper-reference/main/en-us/Global/Debug.html#typo3-fluid-debug) to
debug what kind of
data the variable contains like this:

**packages/my_site_package/Resources/Private/Templates/Partials/Navigation/Menu.fluid.html (changed for debug output)**

```diff
<ul class="navbar-nav mr-auto">
    <f:for each="{menu}" as="menuItem">
+       <f:debug>{menuItem}</f:debug>
        <li class="nav-item {f:if(condition: menuItem.active, then:'active')}">
```

The debug output on your page should now look like this:

```plaintext
array(8 items)
    data => array(78 items)
    title => 'My page' (22 chars)
    link => '/my-page' (26 chars)
    target => '' (0 chars)
    active => 0 (integer)
    current => 0 (integer)
    spacer => 0 (integer)
    hasSubpages => 1 (integer)
```

The following data is of interest:

-   **`{menuItem.data}`:**

    Contains the raw data of the [database record](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Database/DatabaseRecords/Index.html#database-records)
    of the page for the menu item.

-   **`{menuItem.link}`:**

    The actual link to the page. For external links it contains the URL.

-   **`{menuItem.target}`:**

    This might contain "\_blank" if the menu item represents an external link.

-   **`{menuItem.title}`:**

    The title to be displayed in the menu. By default the navigation title if set,
    the title otherwise.

-   **`{menuItem.active}`**

    Contains 1 if the page of the current menu item is in the rootline of the
    current page.

The construct `{f:if(condition: menuItem.active, then: 'active')}`
output the string "active" if `{menuItem.active}` is set. The syntax might look
confusing at first. It is an
[f:if ViewHelper](https://docs.typo3.org/other/typo3/view-helper-reference/main/en-us/Global/If.html#typo3fluid-fluid-if)
displayed in the [Fluid inline notation](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Fluid/Index.html#fluid-inline-notation).

## Preview the page and use the menu {#main-menu-creation-preview}

Whenever you change TypoScript files or Fluid templates, flush all caches:

```bash
ddev typo3 cache:flush
```

![Checking from the backend if the menu is generated as expected.](../Images/MainMenuCreation/CheckMainMenu.png)

## Different menu types {#menu-types}

We use the [menu data processor](https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/DataProcessing/MenuProcessor/Index.html#MenuProcessor)
to demonstrate different menu types:

-   A breadcrumb configured in
    `packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/breadcrumb.typoscript`
    and rendered in `packages/my_site_package/Resources/Private/Templates/Partials/Navigation/Breadcrumb.fluid.html`.
-   A footer menu consisting of pages within a selected folder configured in
    `packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/Navigation/footerMenu.typoscript`
    and rendered in `packages/my_site_package/Resources/Private/Templates/Partials/Navigation/FooterMenu.fluid.html`.
