Building Menus#

Complete guide to creating and structuring menus with Menu and MenuItem.

Providing Extra Context#

The renderer class will pass all the basic context necessary to build your menu templates. However, you can also provide extra context data on a per-item basis using the extra_context parameter.

MenuItem(
    name="special",
    url="/special/",
    extra_context={
        "icon": "star",
        "badge": "New",
        "highlight": True,
    },
)

You will now have access to {{ icon }}, {{ badge }}, and {{ highlight }} in your menu templates.

Note

Extra context is merged with the standard context provided by the renderer. This means that you should avoid using keys that the renderer relies on or things may break.