I'm migrating a Drupal 7 site to Drupal 8.

The old site uses $ drush block_configure (available in Drush extras) to put blocks in regions while deploying, as well as $ drush block-disable to remove unwanted blocks. Unfortunately, Drush extras is no longer available for Drush 8, which seems to be the first version supporting Drupal 8.

The site will be deployed multiple times by multiple people, so adjusting region settings manually in admin view is not a solution. Everything needs to be done in an Ansible playbook so it can be passed on easily.

It seems that configuration management can be used to move blocks, but this would require all the environments to have up-to-date copies of a master database. While this is not impossible, it does feel like a hassle and a possible security risk. The developers don't really need to have all production data in their dev environments, and I wouldn't want to put production data on servers using developmental (and possibly vulnerable) code.

Twig Tweak seems to have an option to render a block anywhere regardless of regions. However, if I hardcode all blocks on templates, admins can no longer use admin block management.

Would it be possible to write a custom module and use block alter functions to set regions on blocks created by core modules? Are there any examples of this?

Are there more ways I'm not aware of? What is the best practice?

  • "but this would require all the environments to have up-to-date copies of a master database" It would not.
    – ya.teck
    Commented Mar 1, 2018 at 8:09
  • block of content or block creates by code? Commented Mar 1, 2018 at 20:31
  • @ya.teck Can you elaborate? What other setups are possible?
    – Meepu
    Commented Mar 3, 2018 at 18:59
  • @AdrianCidAlmaguer Blocks created by core modules, contrib modules and custom modules. No blocks are created manually.
    – Meepu
    Commented Mar 3, 2018 at 19:02

1 Answer 1


I was able to accomplish what I wanted using theme config, as described in How to assign blocks to particular regions on theme install? . This solution works for me, because my site will only ever use one (custom) theme, and I don't mind configuring all blocks this way.

I created a config file (this one is for a language switcher, provided by language module) and put it in MYTHEME/config/install/block.block.MYTHEME_BLOCKNAME.yml. It's just what you would export from configuration management, without uuid.

langcode: en
status: true
    - language
theme: MYTHEME
region: header
weight: -6
provider: null
plugin: 'language_block:language_interface'
  id: 'language_block:language_interface'
  label: 'Language switcher'
  provider: language
  label_display: '0'
visibility: {  }

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.