wickywills
8/9/2017 - 9:59 AM

Extending

Extending

For best practice, it is best to extend a master template file when working with Twig templates. So the master file would look something like this:

<!DOCTYPE html>
<html>
    <head>
        <title>{{ wp_title }}{{ site.name }}</title>
    </head>

    <body class="site {{ classes }}">

        {% include 'components/header/header/template.twig' %}

        {% block content %}{% endblock %}

        {% include 'components/footer/footer/template.twig' %}
    </body>
</html>

And your templates would extend master:

{% extends 'components/common/master/template.twig' %}

{% block content %}
  <p>Your template content goes here</p>
{% endblock %}

More info can be found at https://twig.symfony.com/doc/2.x/tags/extends.html