I have a custom module that is intended to be deployed as a pure web view, with no styling whatsoever beyond what I created in the .twig file.

I installed the Stark theme and in my local instance I went to Admin > Structure > Block layout to manually remove all the active blocks.

However, this module will be deployed and I will have to have it programmatically remove all blocks when integrated into the mobile client.

Is there a way to turn off any automatic/default activation of blocks?

  • 1
    Did you consider a custom theme that doesn't render any regions? So your page.html.twig only contains something like {{ page.content }} and nothing else? Mar 7, 2016 at 20:27
  • Either that, or a custom page--path.html.twig that doesn't print those regions, hook_block_access() on your module on those pages or just build your own output with your own custom twig template and return it as a plain Response object.
    – Berdir
    Mar 7, 2016 at 23:53
  • @marcvangend - Thanks. I did try that a couple of different ways (altering page.html.twig and using hook_page_alter to unset all other regions) and unfortunately all the blocks just moved over to the content block. :(
    – oaklandj
    Mar 16, 2016 at 23:35

1 Answer 1


You can use hook_preprocess_html(). For example, to remove the system navigation block from the "sidebar_first" region, define the following hook in your MODULE.module:

function MODULE_preprocess_html(&$variables) {
    $variables['page']['REGION']['BLOCK']['#access'] = FALSE;

with REGION = sidebar_first and BLOCK = system_navigation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.