0

my folder structure looks something like this:

πŸ“‚ themes
└─ πŸ“‚ foo
   β”œβ”€ πŸ“‚ bar
   β”‚  β”œβ”€ πŸ“‚ templates
   β”‚  β”‚  └─ πŸ“„ node.html.twig
   β”‚  └─ πŸ“„ bar.info.yml
   β”œβ”€ πŸ“‚ templates
   β”‚  └─ πŸ“„ page.html.twig
   β”œβ”€ πŸ“„ foo.info.yml
   └─ πŸ“„ foo.libraries.yml

now I run a multisite. one site is using the foo theme and the other uses bar.

The site using the foo theme also invokes the template /theme/foo/var/templates/node.html.twig

  1. Why is that so?
  2. I thought the foo theme only invokes templates inside its own templates folder? I expected this to be the point of the templates folder. Is that assumption wrong?
  3. can I prevent this behavior without moving the subtheme somewhere else?

2 Answers 2

1

Themes are not allowed to be placed inside one another, as oppose to modules. Even though it works, there are undesired side effects.

0

This directory structure is shows one single theme called foo. The sub-directory bar has no meaning at all for Drupal, it is below /themes/fooand as such part of foo.

Your node file has to go into /themes/bar/templates/OPTIONAL/SUBDIR/DOES/NOT/MATTER/node.html.twig

Every theme, even subthemes, has to go in it's own /theme-directory. Please red read the docs for sub-themes.

2
  • How and where do the docs answer the question?
    – loominade
    Oct 18, 2019 at 9:02
  • The very first words on the sub-themes docs page are "Sub-themes are just like any other theme". As your main theme foo already has a correct file and folder structure, it seems you already know how to create a theme. Do the same with the sub-theme, but add the basethemekey in the YAML
    – Hudri
    Oct 18, 2019 at 9:16

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.