In Drupal 7 and older, primary and secondary links (menus) have always been handled differently than other menus. Primary and secondary links are intended to display important links that are featured in themes. This led to an architecture supporting the primary and secondary links that became rigid and hardwired in its implementation, because it was closely intertwined with themes.
In Drupal 8, primary and secondary links have become unspecialized. They have been converted to blocks and are now managed just like any other block. A theme can still choose to provide "primary and secondary links" functionality, by adding the "Primary menu" (primary_menu
) and "Secondary menu" (secondary_menu
) regions. These regions are intended to be used by only a single block at a time, and only by menu blocks (just like the names suggest). This is what the default page.html.twig
does (which custom themes inherit unless they overrides it) and what the default front-end theme — Bartik — also does.
API changes
- The primary and secondary menus are converted into blocks, and therefore no longer available as theme settings or as variables in the page template.
- The following API functions are removed:
function menu_main_menu()
menu_secondary_menu()
_menu_get_links_source()
menu_navigation_links()
- The primary and secondary menu settings are removed from
menu_ui.settings
andtheme.settings
. - Two new regions in Bartik:
primary_menu
andsecondary_menu
.
Comments
This part of the new design
This part of the new design just does not make any sense to me.
A theme can still choose to provide "primary and secondary links" functionality, by adding the "Primary menu" (primary_menu) and "Secondary menu" (secondary_menu) regions. These regions are intended to be used by only a single block at a time, and only by menu blocks (just like the names suggest).
I mean either we go all in with the design change or not.
Sachin Patel
It means that for D8 it is not necessary to print the primary menu and secondary menu in page.html.twig as we do for D7. In D8 primary and secondary menu are available as blocks "Main Navigation & User account Menu" respectively. You can choose where to display the menu from block settings.