Score:0

Twig\Error\LoaderError: Template "@theme/footer.html.twig" is not defined

no flag

I know there are similar questions to this that have been asked but none of the solutions are working for me and I've been at this all day so I thought I'd give this a try.

I've created a sub-theme of Bartik for Drupal 9. I've copied the page.html.twig and I'm trying to include a templates/includes/footer.html.twig and nothing I have tried has worked.

  1. I installed the components module and updated DB

  2. Declared the following in subbartik.info.yml:

    components:
      namespaces:
        includes: includes
    
  3. Input the following into page.html.twig

    {% include '@includes/footer.html.twig' %}
    

Cleared cache with drush, and I get error:

    Twig\Error\LoaderError: Template "@includes/footer.html.twig" is not defined in "sites/default/themes/custom/subbartik/templates/page.html.twig" at line 125. in Twig\Loader\ChainLoader->getCacheKey()
  1. I've tried a relative path from web folder root

    {% include 'sites/default/themes/custom/subbartik/templates/includes/footer.html.twig' %}
    

Same error:

    Twig\Error\LoaderError: Template "sites/default/themes/custom/subbartik/templates/includes/footer.html.twig" is not defined in "sites/default/themes/custom/subbartik/templates/page.html.twig"
  1. I tried the old:

    {% include '@subbartik/includes/footer.html.twig' %}
    

Same error:

    Twig\Error\LoaderError: Template "@subbartik/includes/footer.html.twig" is not defined in "sites/default/themes/custom/subbartik/templates/page.html.twig"

Any suggestions would be appreciated. Thanks!

UPDATE

File structure (figured it would just be easier to take a screen shot):

file system of drupal project starting at root, then web, sites, default, themes, custom, subbartik

Alireza Tabatabaeian avatar
cn flag
sites/default/themes? in drupal 9? where have you put your theme? it is not drupal 7 any more
tWoolsey avatar
no flag
This is a local dev environment. It's inside the web/ directory.
Alireza Tabatabaeian avatar
cn flag
Can you provide your file structure?
tWoolsey avatar
no flag
Yes, I updated the post with a screen shot of my file structure. Thanks.
leymannx avatar
ne flag
Put it in web/themes/custom
tWoolsey avatar
no flag
Hi leymannx. Thanks for the reply but that can't be what's causing the problem. I have cloned sites from other developers running on my local machine and their custom themes are in web/sites/default/themes and the include functions work fine. Besides, when I'm done with this it has to go up to a production environment where all the folders need to be contained within the sites/default/ structure.
Score:1
no flag

There was a caching problem that had nothing to do with the template itself. Not sure exactly what happened but I turned off MAMP, did something else for awhile, came back and it was working fine. Thanks!

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.