I have a content type I added with the machine name news.

Per this post and this page I have set up node--news.html.twig pushed to Acquia successfully and cleared all caches.

The answer on this post says my file name should work.

This page says same thing: "Content specific node templates is simple - node--[content-type-machine-name].html.twig, e.g. node--article.html.twig, clear the cache."

I have twig debugging enabled and if I add page--node--336.html.twig it works as expected. Debugging output using node--news.html.twig:

<!-- FILE NAME SUGGESTIONS: * page--node--336.html.twig * page--node--%.html.twig * page--node.html.twig x page.html.twig --> <!-- BEGIN OUTPUT from 'themes/fimc/templates/page.html.twig' -->

I have also tried page--node--news.html.twig with no success.

What am I doing wrong?

  • 3
    You are mixing the page and the node templates. A page consists of dozens of different templates. node is for just the main content part (= the node) while the page is for the whole page with all the regions. The page doesn't have a per-node-type variant, but you could add that if you want yourself
    – Berdir
    Commented May 7, 2018 at 20:34
  • @Berdir can you direct me to docs for how to do that? Commented May 7, 2018 at 20:35
  • 1
    The question has now been marked as a duplicate of one that answers exactly that. That said, I would also suggest you re-evaluate your options, the page template in 8.x was refactored to basically just be built of regions with blocks inside. I would suggest you check if what you're trying to do can't be achieved with blocks and visibility configuration as that might result in better performance/cacheablity than having logic outside of blocks directly in the page template. There are also valid use cases for needing such a template suggestion of course.
    – Berdir
    Commented May 7, 2018 at 22:02
  • Thank you @Berdir . I got it working using the solution in the duplicate question but I am baffled by the number of places I see node--[content-type-machine-name].html.twig cited as though it should work out of the box. Commented May 7, 2018 at 22:28
  • 1
    It does work out of the box for the node template, but you are not working with the node template, you are working with the page template. Suggestions are separate for each template.
    – Berdir
    Commented May 8, 2018 at 6:18


Browse other questions tagged or ask your own question.