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

VM’s picture

I suggest starting with twig themeing guide @ https://www.drupal.org/theme-guide/8/twig

keneso’s picture

I've read it, more than once, but still missing it ... could you please give me a practical example?

Anonymous’s picture

Just in case you haven't solved this problem, you need to do something like
{% include 'custom/MYTHEME/templates/my-file.html.twig' %}

jmsosso’s picture

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.

function hook_theme() {
  return [
    [...]
    'my_file' => [
      'variables' => [
        'xxx' => NULL,
      ],
    ],
  ];
}

Then {% include 'my-file.html.twig' %} will works.