Theme Layouts


Theme Layouts are the outer most structural layout of your website. The theme layout is responsible for high level structural blocks and positioning the content block.

Theme layouts should be defined within the theme's resources/views/layouts directory:

{% verbatim %} <!doctype html>


    {% block metadata deferred %}
    {% include "theme::partials/metadata" %}
    {% endblock %}


{% block header deferred %}
{% include "theme::partials/header" %}
{% endblock %}

<main id="main">
    <div class="container">

        {% include "theme::partials/messages" %}

        <div class="col-lg-8">
            {% block content %}{% endblock %}

        <aside class="col-lg-4">
            {% block sidebar deferred %}
                {% include "theme::partials/sidebar" %}
            {% endblock %}


{% include "theme::partials/footer" %}

{% block js deferred %}
{% include "theme::partials/js" %}
{% endblock %}


{% endverbatim %}

The above layout is a slightly modified version of what Pyro will make for you using the make:addon command (see creating an addon).

Content Block

The output generated from PyroCMS is always defined as content so use {% verbatim %}{% block content %}{% endblock %}{% endverbatim %} or {% verbatim %}{{ block('content') }}{% endverbatim %} to include that content block in your layout.

Keep in mind that if you are building your own content system and are not using Pages or Posts for example but maybe just Streams instead; you are free to use any content organization and delivery you want.

Deferred Blocks

Deferred blocks are processed last. Deferring blocks give the internals of the contents block a chance to manipulate the environment before rendering them.

Internally generated content might dynamically load styles or scripts into the styles.css or scripts.js collections, a template global value, or anything else you need to pass backwards in the outer layout.

For more information on how to use Twig please checkout their documentation.