I have created a custom block type with the machine name "score_card". I am displaying it on a node page via a paragraph with an entity reference field that references blocks. I would like to get a template suggestion for it along the lines of "block--block_content--score-card.html.twig".

I have template suggestions turned on and I do see suggestions in the HTML output for the paragraph, the reference field and the individual custom block type fields. There are no suggestions shown for blocks at all, not even block.html.twig. Attempting to just place 'block--block_content--score-card.html.twig' or 'block--score-card.html.twig' in my theme has no effect.

I also attempted to generate the theme suggestion using the suggested fix in this thread of adding hook_theme_suggestions_block_alter to no effect. Running this code through the debugger shows that the hook is not called for the block referenced via a field.

Using Drupal 8.9 latest how can I implement a custom theme for a custom block type referenced via a an entity reference field?

  • Can template names contain underscores?
    – leymannx
    Commented Mar 3, 2021 at 19:39
  • @leymannx It's possible I have the wrong translation of machine name to template name - which I think is what you are getting at. However that doesn't change the fact that I have no template suggestions (for this block only, ok for everything else) and that the debugger shows that hook_theme_suggestions_block_alter isn't even called for this block.
    – lolcode
    Commented Mar 4, 2021 at 14:02
  • I edited the question to reflect @leymannx 's comment by changing the template suggestion example to kebab case.
    – lolcode
    Commented May 6, 2022 at 20:25

1 Answer 1


I finally got some nice simple template suggestions by using the Block Content Template module. Found it from recent discussion in a core issue. Thanks to all involved.

For example this gives me : block-content--55.html.twig, block-content--hero.html.twig and block-content.html.twig when rendering a block content attached to an entity reference field.

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.