Drupal 8: Include A Twig Template

1st April 2016 - 2 minutes read time

When creating re-usable theme templates in Drupal 8 it's quite easy to include that template by using the following snippet.

{% include directory ~ '/templates/parts/footer.html.twig' %}

This assumes that your footer.html.twig template file is kept in the same theme as the template you are working on. It's also good practice to add the template part to a directory called 'parts' or 'components' to separate them from the normal Drupal templates.

Comments

Add new comment

The content of this field is kept private and will not be shown publicly.