I am using a custom Theme in a multisite setting. With the help of @leymannx I implemented hook_theme_suggestion_HOOK_alter to insert a page Template with the following naming convention: page--NAMEOFSUBSITE.html.twig

See here

If I try to do the same for the node of my content type, which is using a template named node--CONTENTTYPENAME.html.twig at the moment, I can insert a name suggestion node--NAMEOFSUBSITE.html.twig, which will then be used for ALL nodes. I'd like to insert a suggestion such as node--CONTENTYPENAME--NAMEOFSUBSITE.html.twig, for only this one nodetype.

How can I do that?

Thanx in advance!!

2 Answers 2


Activate twig debug and use the browser inspector to see the template precise name available for your content-type Do a cache rebuild when the temaplte is created to make it happen.


MYTHEME_theme_suggestions_node_alter() should look somewhat like this:

function MYTHEME_theme_suggestions_node_alter(array &$suggestions, array $variables) {
  $site_path = \Drupal::service('site.path');
  $site_path = explode('/', $site_path);
  $site_name = $site_path[1];
  $type = $variables['elements']['#node']->getType();
  $suggestions[] = 'node__'.$type.'__' . $site_name;


I found this kint() inspecting the variables within the hook, then finding the methods defined on ['#node'].

Your Answer

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