I've read numerous answers to similar questions here but I can't for the life of me work out how to do this seemingly simple thing. I simply want to include a Twig template (theme_name/templates/system/footer.twig.html
) from another Twig template in my custom theme (theme_name/templates/system/page.twig.html
).
In my page.html.twig
I've tried all of the following (obviously with theme_name
as the actual theme name):
{% include 'themes/custom/theme_name/templates/system/footer.html.twig' %}
{% include 'footer.html.twig' %}
{% include 'system/footer.html.twig' %}
{% include directory ~ '/system/footer.html.twig' %}
{% include '/' ~ directory ~ '/system/footer.html.twig' %}
{% include "@theme_name/system/footer.html.twig" %}
{% include "/var/www/html/web/themes/custom/theme_name/system/footer.html.twig" %}
Each of these produces the following error, with the template varying on the method I've tried:
Twig_Error_Loader: Template "themes/custom/theme_name/templates/footer.html.twig" is not defined (Drupal\Core\Template\Loader\ThemeRegistryLoader: Unable to find template "themes/custom/theme_name/templates/footer.html.twig" in the Drupal theme registry.) in "themes/custom/theme_name/templates/homepage/page--front.html.twig" at line 177. in Twig_Loader_Chain->getCacheKey() (line 115 of /var/www/html/vendor/twig/twig/lib/Twig/Loader/Chain.php).
I've even tried using hook_theme
in my theme_name.theme
file to no avail.
<?php
function my_theme_theme() {
return [
'footer' => [
'variables' => [],
],
];
}