I have page.html.twig file in drupal 8X version in that file how to include header.html.twig file which is located as includes directory in same theme directory
1 Answer
The correct method for Drupal 8 themes is to use Twig namespaces to declare the current theme "templates" directory. Here is an example:
{% include '@THEME_NAME/includes/header.html.twig' %}
Below is an example taken from a working theme on Drupal.org called Architect. "@architect" refers to /templates in the working theme (architect) directory.
{% include '@architect/includes/header.html.twig' %}
2 Comments
venky
It's not working while add a twig in mentioned above shows some error like "The website encountered an unexpected error. Please try again later."
MilanG
"Unexpected error" is message for site visitors, not for developers. Check on some error log (Reports > Recent log messages) or enable error reporting to see what's really going on there. Maybe you are trying to include unexisting template file or something.