Layouts

How Layouts Work

TemplateX compiles the page content first, then renders it through the selected layout.

Page Content#

A route template can stay focused on the page:

phpresources/views/front-page.php
<main>  <h1>{{ title }}</h1>  {{ content }}</main>

Layout Shell#

The layout owns the shared document markup:

phpresources/views/layouts/default.php
<!doctype html><html><body>  {{ slot }}</body></html>

When layout files exist, TemplateX wraps normal WordPress templates with the selected layout.

Templates inside resources/views/layouts are layout files themselves, so they are not wrapped by another layout.