Following this answer, I'm trying to override core/themes/seven/templates/node-add-list.html.twig using hook_theme_suggestions_HOOK.

So, I added the following function in modules/custom/domain_filter/domain_filter.module

function domain_filter_theme_suggestions_node_add_list(array $variables) {
  $suggestions = [];
  $suggestions[] = 'node_add_list__' . 'custom';
  return $suggestions;

I created the custom twig file in my module: modules/custom/domain_filter/templates/node-add-list--custom.html.twig

The suggestion appear well in theme debug but it's not applied (the x is in front of node-add-list.html.twig):

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'node_add_list' -->
   * node-add-list--custom.html.twig
   x node-add-list.html.twig

How to apply node-add-list--custom.html.twig?

2 Answers 2


Finally I found a paragraph in the documentation. When using modules, we need to register the template using HOOK_theme(). So, I added the following function in modules/custom/domain_filter/domain_filter.module

 * Implements hook_theme().
function domain_filter_theme() {
  return [
    'node_add_list__custom' => [
      'base hook' => 'node_add_list',

Then my custom template modules/custom/domain_filter/templates/node-add-list--custom.html.twig is now applied.


you need add to your theme

  • Thanks, this can be useful when you create a subtheme or a new theme but I just want to use a module.
    – Kwadz
    Sep 13, 2018 at 9:39

Your Answer

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

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