Skip to main content

wagtailmenupage: Add custom menu items and external links with Wagtail's native menu system.

Installation

Install the package:

# With pip
pip install wagtailmenupage

# Or Poetry
poetry add wagtailmenupage

(Or your prefered package manager)

Run migrations:

# Standard Python
python ./manage.py migrate

# If using Poetry
poetry run python ./manage.py migrate

Add to your INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "wagtailmenupage",
    ...
]

Usage

Creating a page

You can add a new Page type for menu items:

Demo screenshot 1

The 'Page' itself is very stripped down. It supports only 3 fields:

Demo screenshot 2

Setting up the template

You can then build a menu using Wagail's built-in system, but these page items will show the correct label and URL:

{% load wagtailcore_tags menupage_tags  %}
{% get_site_root as site_root %}

<nav role="navigation" aria-label="Main navigation">
    <ul>
        {% for menu_item in site_root.get_children.live.in_menu.specific %}
            <li>
                <a
                    href="{% pageurl menu_item %}"
                    {% if request.path == menu_item.url %}aria-current="page"{% endif %}
                    {% if menu_item.open_in_new_tab %}target="_blank" rel="noopener noreferrer"{% endif %}
                >{{ menu_item.title }}</a>
            </li>
        {% endfor %}
    </ul>
</nav>

The above example doesn't show multi-level menus, but that can be done in the regular Wagtail way.

Take note of the logic for opening in a new tab, which is specifically required for this package's open in new tab functionality to work.

You can then re-order your menu items like normal.

For more guidance on using Wagtail menus, please refer to their documentation

Notes

These pages are excluded from the site search, don't use previews, and are excluded from sitemaps generated by the wagtail-seo package.

Metadata

Release files for wagtailmenupage 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wagtailmenupage 1.2.0
File Size Uploaded
wagtailmenupage-1.2.0.tar.gz 84.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wagtailmenupage 1.2.0
File Interpreter ABI Platform
wagtailmenupage-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 92.1 kB

Release files / wagtailmenupage-1.2.0.tar.gz

Download URL wagtailmenupage-1.2.0.tar.gz
Size 84.6 kB
Tags Source
SHA-256 checksum
How to use checksums
718ac57b2d01c0b5c8380c6d2d9a74a71e9d469d1dcefeeda200eac85380d60e
BLAKE2b-256 checksum
How to use checksums
e097147910930c512314e17083710619ffcde47acfbc6836488ae191ed0d1191
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / wagtailmenupage-1.2.0-py3-none-any.whl

Download URL wagtailmenupage-1.2.0-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c6073197267c61f16083f6017431b462d50adb521a611465b09ba22d89f223bc
BLAKE2b-256 checksum
How to use checksums
ca21d5b9eac2e4d6b5ac4a2bd064a2edb961503bc3c9af335efd54d197b423c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page