1

I enabled theme debugging in services.yml file and I added a template file. Following is what I see in file name suggestions:

x layout--onecol.html.twig * layout-onecol--taxonomy-term--1.html.twig * layout-onecol--taxonomy-term-branches-default.html.twig * layout-onecol--taxonomy-term-branches.html.twig * layout-onecol--taxonomy-term-default.html.twig * layout-onecol--taxonomy-term.html.twig x layout--onecol.html.twig * layout.html.twig

Here's new file's name:

layout-onecol--taxonomy-term-branches-default.html.twig

The file is not recognized. The page is still rendering from

<!-- BEGIN OUTPUT from 'core/themes/stable/templates/layout/layout--onecol.html.twig' -->

So, I tried adding layout--onecol.html.twig file in my custom theme. And this file is recognized which means file names with * in suggestions list are not working, but names with x are recognized.

I believe they should work in opposite way.

  • Is it layout-onecol or layout--onecol? Notice the count of hyphens. Clearly the code suggesting template names with taxonomy terms is different then the default. I'd check out that implementation. Also, wouldn't hurt trying to rename your template to layout--onecol--taxonomy-term-branches-default.html.twig. – osman Apr 8 '18 at 21:00
  • @osman Thanks for reply. it is layout--onecol.html.twig. I've tried layout--onecol--taxonomy-term-branches-default.html.twig. – PHG Apr 8 '18 at 22:16
  • 1
    Did you clear the caches after adding your template? – Jaypan Apr 9 '18 at 2:26
  • The x represents the current theme file name being rendered * represents other available file name suggestions. I don't know why in your case layout--onecol.html.twig comes again at top – Razeem Ahmad Apr 9 '18 at 9:07
  • layout--onecol--taxonomy-term-branches-default.html.twig How you get this suggestion is it through hook_theme_suggestions_HOOK_alter then check the variable passed to $suggestions – Razeem Ahmad Apr 9 '18 at 9:09

Your Answer

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

Browse other questions tagged or ask your own question.