Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By keneso on
Hi
I need to include a file in mt page template, I tried
{% include 'my-file.html.twig' %}
and
{% include 'my-file.html' %}
but the page stays blank.
How should I go about it?
Thank you
Comments
=-=
I suggest starting with twig themeing guide @ https://www.drupal.org/theme-guide/8/twig
Thanks
I've read it, more than once, but still missing it ... could you please give me a practical example?
Just in case you haven't
Just in case you haven't solved this problem, you need to do something like
{% include 'custom/MYTHEME/templates/my-file.html.twig' %}
Define the template in hook_theme()
You need to define the template to include in hook_theme(), as the main one. Then you will be able to include it with only its name, without the full path.
Then
{% include 'my-file.html.twig' %}
will works.