Enabling lb
2. Enabling Layout Builder
When to Use
When you want to enable Layout Builder on a content type, custom entity type, or specific view mode.
Steps
- Via UI
- Navigate to Structure → Content types → [Content type] → Manage display
- Enable "Use Layout Builder" checkbox
- Optionally enable "Allow each content item to have its layout customized"
-
Save
-
Via Configuration
- Edit
core.entity_view_display.{entity_type}.{bundle}.{view_mode}.yml - Add third_party_settings for layout_builder
-
Export or include in recipe
-
Programmatically
use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay; $display = LayoutBuilderEntityViewDisplay::load('node.article.default'); $display->enableLayoutBuilder() ->setOverridable(FALSE) // or TRUE for per-entity overrides ->save(); -
Verify permissions
- "Configure any layout" — administer default layouts
- "Configure editable {entity_type} {bundle} layout overrides" — per-entity layouts
Editor-enablement permission set: to hand LB to a non-admin editor role, grant three permissions:
- configure any layout — static core permission
- create and edit custom blocks — static block_content permission, REQUIRED for inline blocks
- configure editable <entity_type> <bundle> layout overrides — dynamic per-bundle permission generated by layout_builder.permissions.yml permission_callbacks
Prefer the per-bundle editable-overrides permission over configure any layout when you want to scope editors to specific bundles rather than every layout on the site.
- Result: LB enabled, section field added (if overrides), fields converted to blocks in default section
Decision Points
| At this step... | If... | Then... |
|---|---|---|
| Enabling LB | Fresh install or new content type | Enable defaults only first, test workflow before enabling overrides |
| Enabling LB | Existing content with field display config | Fields automatically become field blocks in first section, verify display settings preserved |
| Allowing overrides | Need per-entity layouts | Enable "allow_custom", grants per-entity customization but prevents updating from defaults |
| Allowing overrides | All entities should match default | Leave "allow_custom" disabled, easier maintenance and updates |
Common Mistakes
- Enabling overrides immediately → Start with defaults. Overrides create maintenance burden. Once entity is overridden, default updates don't apply
- Not checking permissions → Different permissions for defaults vs overrides. Configure permissions or editors can't use LB
- Forgetting to save → UI requires explicit save. Config export requires explicit drush cex. Changes aren't automatic
- Not testing field conversion → When enabling LB on existing display, fields become blocks. Verify formatters and labels preserved
- Configuring LB permissions only in the database → If the editor role's LB permissions are never exported to config, the editor handoff silently fails on deploy because the role config doesn't carry the perms. Export the role config after granting them
See Also
- Section 3: Config Schema (YAML structure)
- Section 9: Defaults vs Overrides (choosing between them)
- Reference:
/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php(enableLayoutBuilder method) - Reference:
/core/modules/layout_builder/layout_builder.permissions.yml(per-bundle override permission callbacks)