Twig Loader Error

Created on 4 November 2020, about 4 years ago
Updated 8 June 2023, over 1 year ago

Problem/Motivation

So I've been working on a website building a new subteme with radix via composer, drush and NPM. I get the subtheme working find in my Lando local environment however, when I push the environment to DEV in pantheon, I get the white screen of death and PHP Error: Twig\Error\LoaderError: Template "@radix/nav/nav.twig" is not defined in "themes/contrib/radix/templates/navigation/links.html.twig" at line 7. in Twig\Loader\ChainLoader->getCacheKey() (line 142 of /code/vendor/twig/twig/src/Loader/ChainLoader.php).

I've seen some things online that I should include the twig file at the beginning of the links.html.twig file however it's using embed for the nav.twig file and it should be doing the same thing from what I understand. I'm still very novice at twig and I may be missing something here.

I'm not sure if this is a Pantheon issue, however, running lando, I'm assuming it should mimic the server structure there very closely and I should be getting it both places but I don't.

Steps to reproduce

  1. Spin up new website in pantheon
  2. Pull new site into Lando
  3. composer require drupal/radix
  4. composer require drupal/components
  5. drush en components
  6. drush en radix
  7. drush radix "Sub Theme"
  8. npm install subtheme
  9. enable the subtheme
  10. working on lando, push to pantheon dev
  11. php error: Twig\Error\LoaderError: Template "@radix/nav/nav.twig" is not defined in "themes/contrib/radix/templates/navigation/links.html.twig" at line 7. in Twig\Loader\ChainLoader->getCacheKey() (line 142 of /code/vendor/twig/twig/src/Loader/ChainLoader.php)
πŸ› Bug report
Status

Closed: works as designed

Version

4.10

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States TheGentleman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡¦Ukraine vlad.dancer Kyiv

    Well, it seems after radix update I received same error.
    The fix is quite obvious use full file name: {% extends '@radix/content/node.html.twig' %}

    Using regular expression (?<!html).twig' %} I found couple of places where file names are used w/o "html" part:

    • radix/src/kits/default/templates/content/node.html.twig: {% extends '@RADIX_SUBTHEME_MACHINE_NAME/node/node.twig' %}
    • radix/templates/dataset/table.html.twig: {% include '@radix/table/table.twig' %}
    • radix/templates/menu/menu.html.twig: {% include '@radix/nav/nav.twig' %}

    Looks like we need use suffix .html.twig for templates: https://symfony.com/doc/current/templates.html#template-inheritance-and-...

Production build 0.71.5 2024