Layout Builder Restrictions
Allows site builders to control which blocks and layouts are available for placement in the Layout Builder UI, with configurable restrictions per entity type and view mode.
layout_builder_restrictions
Install
composer require 'drupal/layout_builder_restrictions:^3.0'
Overview
Layout Builder Restrictions supplements Drupal core's Layout Builder module by providing granular control over which blocks and layouts can be placed by content editors. While the core Layout Builder module allows all blocks and layouts to be used by default, this module enables site builders to curate the available options.
Each entity type can individually specify which blocks are available for placement, and each entity's view mode can have different restriction settings. The module provides a flexible plugin architecture that allows different restriction methodologies to be applied, with the default plugin restricting blocks and layouts per entity view mode.
Restrictions can be configured as allowlists (only specified blocks are allowed) or denylists (all blocks except specified ones are allowed), and entire block categories can be restricted. The module also supports restricting inline blocks, custom block types, and content blocks separately, providing maximum flexibility for content governance.
Features
- Restrict which blocks can be placed in Layout Builder per entity type and view mode
- Restrict which layouts are available for adding sections
- Support for allowlisting (allow specific blocks) or denylisting (restrict specific blocks)
- Restrict entire block categories with a single setting
- Separate controls for Custom Block Types, Content Blocks (individual block instances), and Inline Blocks
- Plugin architecture allowing custom restriction methodologies
- Validates block movement via drag-and-drop to enforce restrictions
- Controls for newly available block categories (allow or restrict by default)
- Compatible with individual content item layout overrides
- Submodule for per-layout-per-region restrictions
- Config Actions for programmatic restriction management (Drupal 12+)
- Multilingual-compatible category handling
Use Cases
Restrict content editors to approved blocks only
On a multi-site or enterprise installation, restrict Layout Builder to show only approved, tested blocks. Enable the module, navigate to each content type's display settings, and for each block category, choose 'Allow specific blocks' and check only the blocks that content editors should use. This prevents editors from accidentally using development blocks or blocks that don't match site design standards.
Allow all blocks except specific problematic ones
When most blocks are acceptable but a few cause issues (performance, security, or design), use the denylist approach. For each category containing problematic blocks, select 'Restrict specific blocks' and check only the blocks to hide. All other blocks in that category remain available.
Limit available layouts to match design system
When your theme only supports certain layouts properly, restrict Layout Builder to show only those layouts. In the 'Layouts available for sections' fieldset, select 'Allow only specific layouts' and check only the layouts that have proper CSS/styling in your theme.
Different restrictions per content type
Set up different block availability for different content types. For example, allow promotional blocks on landing pages but restrict them on blog posts. Each entity type and view mode has independent restriction settings.
Per-region restrictions for complex layouts
Enable the 'Layout Builder Restrictions By Region' submodule to restrict blocks to specific regions. For example, allow hero blocks only in a 'banner' region, or restrict sidebar widgets from appearing in main content areas.
Restrict inline block creation
Prevent content editors from creating new inline blocks (which can lead to content management issues) while still allowing placement of reusable blocks from the block library. Restrict the 'Inline blocks' category to control which block types can be created inline.
Programmatic restrictions via Config Actions
For Drupal 12+, use Config Actions in recipes to programmatically set restrictions. Use entityViewModeRestrictionAppendRestrictedBlocks to add blocks to the denylist or entityViewModeRestrictionAppendAllowedBlocks for the allowlist during site installation or configuration updates.
Tips
- Use the denylist approach when most blocks should be available and you only need to hide a few specific ones
- Use the allowlist approach when you want tight control and only specific blocks should be available
- The 'Restrict all existing & new blocks' option is useful for categories you never want editors to use
- Enable 'Restrict all blocks from newly available categories' if you want to manually approve blocks from newly installed modules
- Test restrictions by logging in as a content editor role - admin users may bypass some restrictions depending on permissions
- When using the by-region submodule, you can set restrictions for 'All regions' first, then override specific regions as needed
- Export configuration with drush cex to version control your restriction settings
- Consider combining with Content Moderation for a complete editorial workflow
Technical Details
Admin Pages 2
/admin/config/content/layout-builder-restrictions
Manage which Layout Builder Restrictions plugins are active and their execution order. This page displays a draggable table of all available restriction plugins, allowing administrators to enable/disable plugins and set their weight (execution priority). Plugins with lower weights execute first.
/admin/structure/types/manage/{content_type}
When Layout Builder is enabled for a content type, this form is augmented with restriction settings. Expand the 'Layout options' fieldset to configure which blocks and layouts are available for this entity type and view mode.
Permissions 1
Hooks 3
hook_plugin_filter_block__layout_builder_alter
Alters the list of available blocks in the Layout Builder 'Add Block' UI. This hook is invoked by Drupal core's plugin filterer and allows modules to remove or modify block definitions before they are displayed to the user.
hook_plugin_filter_layout__layout_builder_alter
Alters the list of available layouts in the Layout Builder 'Add Section' UI. This hook allows modules to restrict which layout plugins are available for creating new sections.
hook_form_entity_view_display_edit_form_alter
The module uses this hook to inject the restriction configuration UI into entity view display forms. Other modules can use this hook to further customize the restriction interface.
Troubleshooting 5
When enabling Layout Builder Restrictions By Region after the base module was already configured, you must resave each entity's layout restrictions. Navigate to each content type's display settings and save the form to activate per-region restrictions.
Check multiple places: 1) The block's category may be fully restricted in 'restricted_categories', 2) If using allowlists, the block may not be checked, 3) The 'Default restriction for new categories' may be set to 'Restrict' and the block's category wasn't previously known, 4) Multiple restriction plugins may be active - check /admin/config/content/layout-builder-restrictions.
The module distinguishes between 'Custom block types', 'Custom blocks' (specific instances), and 'Inline blocks'. If you set restrictions on Custom blocks (specific instances), those take precedence over Custom block types restrictions. Check both settings.
The module handles multilingual sites by using untranslated category names internally. If you updated from an older version and have locale module enabled, resave each entity's Layout Builder Restrictions configuration to ensure compatibility.
Ensure the route subscriber service is active. Clear caches with drush cr. The module overrides layout_builder.move_block and layout_builder.move_block_form routes to add validation.
Security Notes 4
- The 'configure layout builder restrictions' permission should be granted only to trusted administrators as it controls what content editors can do
- Restrictions are enforced server-side, not just in the UI - block movement via drag-and-drop is validated against restrictions
- The module does not provide role-based restrictions directly - combine with Drupal's permission system for user-specific restrictions
- Config Actions (entityViewModeRestrictionAppendRestrictedBlocks, etc.) can modify restrictions programmatically - audit any recipes or custom code using these