Exclude and include pages in Drupal 8 block visibility settings

Published June 7, 2020

The standard Drupal 8 block visibility page settings allow you to either include the listed paths (via "Show for all listed pages" or exclude the listed paths (via "Hide for all listed pages") - but you can never include and exclude at the same time. The Block Exclude Pages module provides a solution to this.

Consider the following situation: you have a block that needs to appear at all pages whose URL begins with "/about", with the exception of "/about/me". With just Drupal 8 core visibility rules, it isn't possible to easily make this happen.

With the Block Exclude Pages module installed and enabled, the following visibility rules can then be used:

/about/*
!/about/me

(Show for all listed pages" selected.)

The Block Exclude Pages module allows you to use the "!" character as a negation - problem solved!

Comments

Sign up to receive email notifications of whenever we publish a new blog post or quicktip!

Name
CAPTCHA