I've created a custom module that creates a jumbotron custom block type. The module has an empty .module file and a dir config/install with many .yml files. This works great when I install and create blocks. I can even place my block--bundle--jumbotron.html.twig in the templates folder of the theme and styling works great! I would like this twig file included in the module and many tutorials explain how to do this if you have a build function in your module, I do not. The module is just creating a block type for me.

  • Have you tried placing the Twig file in a templates sub-folder in your module directory?
    – Hudri
    Nov 15 '19 at 13:42
  • This only works if you add the template name as theme hook (with underscores) in mymodule.module, see drupal.stackexchange.com/questions/255813/…
    – 4k4
    Nov 15 '19 at 13:45
  • in the code in this example where 'block__views_block__MYVIEW_block_1' I'm not sure what to put here.
    – Scott
    Nov 15 '19 at 13:54
  • 'block__bundle__jumbotron'
    – 4k4
    Nov 15 '19 at 13:56
  • my 2 days of searching are over! thank you that finally worked!!!
    – Scott
    Nov 15 '19 at 13:58

Create a theme hook with the template name by replacing dashes with underscores:


 * Implements hook_theme().
function mymodule_theme() {
  return [
    'block__bundle__jumbotron' => [
      'render element' => 'elements',
      'base hook' => 'block',
  • worked perfectly !
    – Scott
    Nov 15 '19 at 14:01

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.