In order to print a block in a twig file when using the Twig Tweak module you require the block id, but nothing I am trying will work and I get the message that -

This block is broken or missing. You may be missing content or you might need to enable the original module.


I think your block id is a machine name of a block that you added here: Admin > Structure > Block layout (/admin/structure/block).

When you edit some block you will see the machine name. Besides, a disabled block is also allowed.

enter image description here


You can enable the debug mode for twig template, and then inspect the element. There are in comments with all the id of all the HTML elements. Check this

You enable Twig Debugging in sites/default/services.yml. (If services.yml does not yet exist; copy default.services.yml and copy it to services.yml.)

Set the debug variable to true. And clear cache.

    debug: true 
  • Thanks for this, but I have already got this debug mode working. And can not see anything specifically that states a block id, only template suggestions and the html id of the block, which I have tried also replacing the hyphens with underscores – drupalhgy Apr 10 '18 at 18:21
  • What about this link – ValRob Apr 10 '18 at 18:25

Assuming you are using Twig tweak 2.x the following drush command is suggested by the cheat sheet page.

drush ev "print_r(array_keys(\Drupal::service('plugin.manager.block')->getDefinitions()));"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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