Add block-based site menus (fixes #554)#653
Open
sushanthaaa wants to merge 1 commit intowagtail:mainfrom
Open
Conversation
Replace the page-tree-based show_in_menus navigation with block-based StreamField menus managed as snippets in the Wagtail admin. Changes: - Add MenuItemLinkBlock, MenuItemBlock, MenuSectionBlock to blocks.py - Add FooterMenu model (sectioned footer navigation) - Add MainMenu model (flat top navigation) - Register FooterMenuViewSet and MainMenuViewSet in wagtail_hooks.py - Add get_footer_menu and get_main_menu template tags - Create footer_menu.html and main_menu.html templates - Update header.html and footer.html to use new tags - Add responsive footer menu CSS styles - Add 13 unit tests (7 footer + 6 main menu)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the page-tree-based
show_in_menusnavigation with block-based StreamField menus managed as snippets in the Wagtail admin. Both the main navigation and the footer are now fully editable, supporting custom labels, reordering, external URLs, document links, and a draft/publish workflow with live preview.Closes #554 .
Motivation
The existing navigation relies on the
show_in_menuspage flag, which limits editors to:This PR introduces block-based menus following the wagtail.org navigation pattern, giving editors full control over both the main menu and footer navigation.
Changes
New blocks (base/blocks.py)
New models (base/models.py)
Both use
DraftStateMixin,RevisionMixin, andPreviewableMixin, following the same pattern as the existing FooterText model.Updated files
top_menu{% get_main_menu %}instead of{% top_menu %}{% get_footer_menu %}New files
migrations/0028_footermenu.pymigrations/0029_mainmenu.pyHow to test
python manage.py migratepython manage.py runserverpython manage.py test bakerydemo.base.tests.test_footer_menu bakerydemo.base.tests.test_main_menuTest results
Screenshots
Main_menu

Footer_menu

Admin Panel -

Main_menu
Footer_menu

AI usage
Used Claude Code with model Opus 4.6 for assistance in coding and writing this PR and Reviewed the code and Verified the output personally by me