0

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 1

2

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' %}
Sign up to request clarification or add additional context in comments.

2 Comments

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."
"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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.