Problem/Motivation
Layout Builder is on its way to be removed from Drupal core. However Navigation is the modern admin navigation UI enabled in Drupal core now. That depends on Layout Builder. This means the default install of Drupal needs to enable Layout Builder. There is no other core module that depends on Layout Builder.
@berdir summarized this real well:
layout builder is IMHO too heavy and has too many performance implications just to be able to press that button in the backend
Steps to reproduce
Install Drupal. Observe Layout Builder is enabled. This is confusing if you want to use other page layout solutions.
Proposed resolution
- Refactor Navigation module so it uses a backwards compatible copy of the layout builder section storage but does not itself require Layout Builder.
- Remove the customization UI from Navigation module, so Layout Builder is not even optionally needed by Navigation. (It only needs Layout Discovery).
- Add a new Navigation Layout module that allows to customize the navigation bar. This requires Layout Builder currently.
- Update tests to require Navigation Layout where testing the UI customization.
New default state of Drupal is no Layout Builder is installed.

The same old, confusing, complicated dedicated Navigation Blocks page only shows up when the Navigation Layout module is enabled (previously this same route/page was built into Navigation module):

Performance improvements
- Before scenario is main at 2dbbdd8e171 with Layout Builder installed as navigation's dependency.
- After is the MR branch at bec5c280ce0 with no Layout Builder.
- Both are fresh Standard installs in the DDEV container, served by PHP's built-in server with opcache on, using MariaDB, with identical content.
- Render, dynamic page and page caches were disabled (with those caches enabled the per-request time differences mostly go away; the benefits then are the smaller code footprint and memory on every request); b
- Bootstrap, config and discovery caches were warm.
- Each measurement is from 5 requests per page, median of results is displayed below.
- Time is measured server-side inside PHP. Navigation pages are requested as the admin user, the others anonymous.
- Sample spread is about 0.5 ms, so changes under roughly 3 percent in time are noise (which is most of the cases, so the benefit is most of the cases not in time but memory, although in the node rendering case it was significant time saved!).
| Page | Time (ms) | Peak memory (MB) | PHP files loaded | DB queries |
|---|---|---|---|---|
| Navigation: /admin/content | 38.7 → 37.9 (−2%) | 8.61 → 8.47 (−2%) | 1669 → 1619 (−3%) | 76 → 76 (0%) |
| Navigation: /node/6 | 29.5 → 28.7 (−3%) | 7.15 → 6.94 (−3%) | 1468 → 1389 (−5%) | 60 → 59 (−2%) |
| Navigation: /user/1 | 27.8 → 26.8 (−4%) | 6.76 → 6.57 (−3%) | 1417 → 1338 (−6%) | 56 → 56 (0%) |
| Anonymous: /node/6 | 14.9 → 13.3 (−11%) | 5.88 → 5.72 (−3%) | 1361 → 1315 (−3%) | 14 → 13 (−7%) |
| Anonymous: /user/login | 10.5 → 10.8 (+3%) | 4.76 → 4.67 (−2%) | 1194 → 1186 (−1%) | 9 → 9 (0%) |
| Anonymous: /user/password | 10.4 → 10.7 (+3%) | 4.76 → 4.67 (−2%) | 1196 → 1188 (−1%) | 9 → 9 (0%) |
Takeaways
- Every request gets lighter whether or not Navigation is displayed: 2 to 3 percent less memory and 8 to 79 fewer PHP files without Layout Builder. But time difference is within error.
- The largest relative gain is the anonymous node page at 11 percent, where Layout Builder's entity view display class is not added anymore,.
Remaining tasks
Review.
User interface changes
Users need to install the "Navigation Layout" module to customize the Navigation toolbar. Existing site get it enabled automatically on update.
Introduced terminology
None.
API changes
None.
Data model changes
None. However the format used by Navigation is a manual copy of the layout builder storage. The testing included with Navigation Layout is what makes sure the format stays in sync as those tests keep working.
Release notes snippet
The Navigation module does not offer a customization UI by default anymore. The customization UI has been moved to a new Navigation Layout module. This new module is enabled when you update Drupal if you already had Navigation module enabled. The permission for this interface was already called "Configure navigation layout" so the name of it did not change, but the module providing it did.
However if you don't actually need to customize the UI of the Navigation toolbar, this means that can uninstall this module and consequently uninstall Layout Builder module as well, unless you use that for something else too.
LLM disclosure
Original approach was hand crafted. Separation of the Navigation Layout module was LLM assisted with close human review.
| Comment | File | Size | Author |
|---|---|---|---|
| #46 | 3521159 after, layout, with NL.png | 384.37 KB | csakiistvan |
| #46 | 3521159 after, with NL.png | 198.61 KB | csakiistvan |
| #46 | 3521159 after, without NL, 3.png | 432.6 KB | csakiistvan |
| #46 | 3521159 after, without NL, 2.png | 215.83 KB | csakiistvan |
| #46 | 3521159 after, without NL.png | 380.04 KB | csakiistvan |
Issue fork drupal-3521159
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
catchAdding some related issues from the XB issue queue.
Comment #5
casey commentedI've created a MR that removes the dependency on layout_builder while keeping the same config format for navigation.block_layout. The dependency is removed by simply calling the Layout and Block plugin managers directly.
The UI is still to be replaced. I only emptied navigation LayoutForm and added a new route "navigation.layout" to replace "layout_builder.navigation.view".
Comment #6
gábor hojtsyThis currently moves down the dependency to layout_discovery. Is that a module that stays around in core? (There are a lot more criteria of course, but it is also not depended on by Experience Builder or UI Suite that I could find at least).
Comment #7
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #8
catch@gábor hojtsy layout_discovery provides the layout plugin manager service definition.
#3483307: New `ComponentSource`: `Layout`, to allow for a Layout Builder-to-Canvas migration doesn't depend on the layout_discovery service but it does depend on the same layout plugin manager class that the service uses (which is in Drupal\Core).
So I think that even if we eventually deprecate the layout_discovery module, the layout plugin manager itself will need to exist for quite a long time to support the just in time layout builder -> xb upgrade path. That could mean that navigation module ends up adding it's own version of the layout plugin manager or something like that - but it should be a relatively small incremental step to remove that dependency if/when we get to that point.
Comment #11
berdirRebasing this and trying to move this forward.
The MR currently removes the layout builder integration completely. This seems like a pretty hard change to land as we'd then for now would not have a UI at all.
How about we split this so that we make the layout_builder integration optional just for the UI? My goal for moving this forward is to avoid having to depend on layout_builder at runtime. Because layout_builder comes with significant performance implications right now and has its hooks deep in all kinds of places.
The UI page would then just display a message to enable layout_builder to customize it.
Comment #12
berdirI reverted quite a bit of changes. Navigation works without layout builder being enabled. The backend shows a message to enable layout builder if you don't have it enabled. To make it work, I essentially had to do two non-trivial/annoying things:
* Copy the code of the two traits from layout builder, because missing traits is a parse error and those form classes are loaded during route building. We could possibly maintain two different form classes and dynamically register them, but even the existence of a form class is going to be trouble with route attribute discovery and so on.
* Hardcode the route definition including all the magic bits that layout_builder adds to make things work.
Additionally to the existing duplications like the schema definition. I think that's acceptable as an intermediate step for #3521155: Remove Layout Builder dependency for the UI of Navigation admin config, still use Layout Builder for backend and rendering.
Still struggling with some test fails that I can't reproduce or fail differently for me.
Comment #13
plopescThank you for stepping into this.
Checked the code and looks really promising. Regarding how to deal with the configuration page, maybe a temporary navigation_ui module that enables the access to that page might simplify the things a bit?
Comment #14
godotislateDo you mean like a feature flag module? Except in this case the module would have the layout builder dependency?
I think that might be a good idea.
Comment #15
godotislateSince we're changing navigation config schema here, does it make sense to address or keep in mind changes that we'll need for #3587499: Navigation stores plugin configuration with dependencies in a simple config object?
Comment #16
godotislateSounds like in #3521155: Remove Layout Builder dependency for the UI of Navigation admin config, still use Layout Builder for backend and rendering, the thinking might be to move the UI to a separate module
navigation_uithat eventually moves to contrib, so it probably makes sense to land this close to as is now and then do a follow up to move relevant code including tests to the new module.Comment #17
gábor hojtsyI like this too! We need to define if the customization UI is at all 80% use case assuming contrib can still provide that :)
Comment #18
pameeela commentedI agree that the customisation UI does not need to be in core. Drupal CMS does modify the layout but this is in a recipe so the UI is never needed. There will be sites that want to modify it, but certainly not very often, and it could be done locally for example so you don't need all of the dependencies in production ever.
Comment #19
godotislateMerged main and resolved conflicts (hopefully correctly). @berdir mentioned some outstanding test failures in #12, and there are test failures now. I have not checked if they are the same, but I might look into the test failures later.
Comment #20
godotislateComment #21
berdirLooked a bit at the tests, the UI really is broken right now and doesn't load. Instead of trying to fix that, if we agree that we want to move forward with a navigation_ui module, then I'll refactor that and go back to using the layout builder traits there, that will hopefully fix that.
Comment #22
gábor hojtsy@berdir: let us know when the MR is again ready for review or if you need helping hands :)
Comment #24
quietone commentedThis is waiting on a decision about having a navigation_ui module. See #21. Changing to needs review for that discussion/decision.
And I did a rebase.
Comment #25
gábor hojtsyI think moving the Layout Builder related code out to its own UI module is the best choice. The UI is very awkward anyway (last I tried a couple months back and nothing changed in the meantime) and Layout Builder is on its way out of core.
Comment #26
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #27
gábor hojtsyI used some LLM assistance to rebase and start resolving some new fails. The moved code sections for shortcuts especially needed to be taken care of.
Comment #28
gábor hojtsyNow it all passes green again, so I'm looking at decoupling the LB integration to its own module :)
Comment #29
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. The merge request has merge conflicts and cannot be merged. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #30
gábor hojtsyUpdate title and issue summary.
MR is green.
I think this is done-done unless we want to install the Navigation UI automatically on a site update (which I think is debatable). The release notes snippet explains you can even uninstall Layout Builder if you only used for this. (I don't think we have a way to automatically detect that situation though).
Please try and review. :)
Comment #31
gábor hojtsyAdded screenshots from my local setup.
Comment #32
gábor hojtsyAdding this priceless quote from @berdir to the issue summary:
Comment #33
longwave"Navigation UI" is a confusing name to me, because the primary purpose of the Navigation module is already to provide a UI. Even the issue summary says "Navigation is the modern admin navigation UI", using the same name in a different context.
Is "Navigation Layout Builder" a better name, seeing as it combines those two things?
Comment #34
pameeela commentedAgree re: naming, but "Navigation Layout Builder" also feels misleading because you were never really building a layout, just placing and reordering menu blocks (you can't choose columns etc which to me is what building a layout really means).
What about just "Navigation Layout" (consistent with Block layout) or "Navigation Manager"?
Comment #35
gábor hojtsyI agree navigation UI was very confusing but I did not have better ideas. Navigation Layout is simple and very good IMHO :) Did that.
Comment #36
gábor hojtsyRenaming issue following module rename. Also making it clear that this is the existing code split, its not new code :)
Comment #37
gábor hojtsyComment #38
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. The merge request has merge conflicts and cannot be merged. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #39
kim.pepperThe IS says:
Is this true? Where is the issue that made that decision?
Comment #41
acbramley commentedRebased with a lot less changes since shortcut has been removed.
Used our new fancy performance test update environment variable to regenerate the metrics too :)
Comment #42
gábor hojtsy@kim.pepper: I did not find where we documented that, so opened #3619180: [policy, no patch] Move Layout Builder module to contrib now. However that was at the same discussion at DrupalCon Vienna where we discussed also removing the block UI, see #3555047: Add a way to ship block placement statically (will be useful when block UI is removed). Basically the idea is that Drupal core would not have a UI to structure pages and you would pick whichever you wanted, be if layout builder or canvas or paragraphs or display builder. Eg in #3521155: Remove Layout Builder dependency for the UI of Navigation admin config, still use Layout Builder for backend and rendering @catch writes It seems likely that this won't be the last blocker to deprecating layout builder.
We also need an issue about manage display which is the third layout builder in core on the side of Layout Builder and blocks, but I don't 100% remember what was the direction discussed there, maybe @catch does?
Comment #43
quietone commentedJust tweaking the title
Comment #44
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #45
acbramley commentedComment #46
csakiistvan✅ Tested and works — MR !11972. A do fresh Standard install no longer enables Layout Builder (only Layout Discovery), and the navigation sidebar and top bar render fine without it. With Navigation Layout uninstalled the "Navigation blocks" page is gone and its route 404s; installing Navigation Layout brings Layout Builder back in as a dependency and restores that page, where placing a menu block and saving it showed up in the sidebar right away. Navigation Layout can then be uninstalled on its own without taking Navigation with it, and no errors were logged in any of the three states. Based on this I would suggest RTBC.
Comment #47
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. The merge request has merge conflicts and cannot be merged. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #48
gábor hojtsyMake title clearer as people were taken by surprise that its proposing to add a new layout tool. Its just moving code around.
Updating issue summary for current module name. Also mention upgrade path and permissions.
All concerns on the issue are resolved so should be ready for review again :)
Comment #49
gábor hojtsyEven more clearer title. Sorry for ping-ponging on this.
Comment #50
gábor hojtsyAdded extensive performance measurements. Tagging for that too, since that is a key motivation for this issue.
Comment #51
gábor hojtsyFormatting.
Comment #52
gábor hojtsyComment #55
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. The merge request has merge conflicts and cannot be merged. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #56
csakiistvanComment #57
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #58
gábor hojtsyComment #59
csakiistvanComment #60
csakiistvan@gábor hojtsy I tested again and it looks good and same as on #46 previous state. Based on this I would suggest RTBC.
Comment #61
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #62
finnsky commentedGreat initiative!
I'll rebase and test.
Comment #63
finnsky commentedI tested various layout change scenarios—everything works as expected!
+1 for RTBC - frontend is good! Thank you!
Comment #64
finnsky commentedComment #65
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #66
anybodyRe-confirming RTBC!
Comment #67
godotislateThere's a merge conflict in the MR, so back to NW.
Comment #69
timohuismanI rebased the MR on main.
Comment #70
anybodyThanks, well done! Back to RTBC!