this is my second week with drupal 8 (or drupal in general). I want to be a drupal developer and contributer to the modules and themes community. However, I am a little lost with the file name suggestions shown in this image. Twig filename suggestions

When reading books and tutorials, i see the author suggesting we use one of the filename suggestions shown, but how do you know which one to select? So like in that list, the author switched from the default selected which is the last one, to the second from top. What criteria did he use to determine which is best? Thanks in advance.

1 Answer 1


It depends on how specific you want to get. If you made a template for block.html.twig it would effect every block. block--system.html.twig would effect all of the system blocks, and block--system-branding-block.html.twig would effect the every branding-block subset of the system-block. And block--octo-branding.html.twig could possibly be every block that is using the octo-branding block plugin.

I'm not positive what template is what in your case since I don't know what is named what in your theme and plugins, but that's my best guess. Regardless the rule of thumb is it goes from most specific to most broad in order. And Drupal will use whatever template is most specific that applies in every case. For example.

I have a basic page located at /node/18. Near the top it says

   * page--node--18.html.twig
   * page--node.html.twig
   x page.html.twig-->

If I made a template for page.html.twig, it would load that template for every page. If I made a template for page--node.html.twig it would use that template for every page for nodes. If I made a page--node--18.html.twig it would use that template only for that specific node. If I've already made any combination of those templates Drupal will use the most specific one.

  • 1
    Okay..thats cool. I now have an idea of what is going on. Am sure with a little practice and experimentation, I will have a clear picture. Thanks a Lot Matt.
    – Sean
    Dec 8, 2016 at 14:56
  • No prob. Let me know if you have anymore questions. Are you making your own theme?
    – Amy
    Dec 8, 2016 at 17:46
  • Yea..I have this idea to make a price comparison site for my country, (Kenya), and I thought that a CMS was a good way to start. I'm a college informatics student so i dont have the experience and knowledge to make a site like [pricerunner.com]. So i sought out some wordpress themes but they were all disappointing. switchin to drupal 8, i realized it doesnt have such themes and modules for price comparison, so i decided to learn how to make themes and modules to use in my site, and maybe contribute to the community for others to use. Its also good place to start my programming career.
    – Sean
    Dec 8, 2016 at 22:27
  • Whats's your drupal life been like? Do you make themes yourself and for how long?
    – Sean
    Dec 8, 2016 at 22:33
  • It will be a bit easier if we use a chat room chat.stackexchange.com/rooms/49842/…
    – Amy
    Dec 9, 2016 at 14:45

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.