Who this is for. The theme developer looking at a page that renders with a template they did not expect, and anyone deciding where a new template has to go. Afterwards you can trace any record to the file that renders it, in either engine.
Record, layout, template
The route decides which controller handles a URL and which record it loads; it does not decide the template. For most content records the controller then asks the record's live revision for its layout, and the layout's Template field names the file:
- The visitor opens
/developer-docs; the Pages module loads the page with that path. - The page's live revision is on the layout Hub Developer Docs.
- That layout's template is
pages/pages/hub-devdocs.html, and the controller renders it instead of its default. - The engine finds the file through the resolution order.
The layout belongs to the revision, so an editor who changes a page's layout in a new draft changes nothing on the site until that revision goes live. The engine plays no part in any of this: the same record picks the same file on a Smarty site and on a Twig site.
Which records follow their layout
| Record | Template | Variable it arrives as |
|---|---|---|
| Page | Its live revision's layout, else pages/pages/show.html | page and record |
| Blog post | Its live revision's layout, else blogs/posts/show.html | post and record |
| A blog's post listing | The blog's layout, else blogs/posts/index.html | blog and record |
| Book page | Its live revision's layout, else books/pages/show.html | page and record |
| FAQ page, FAQ question | Its live revision's layout, else faq/pages/show.html or faq/questions/show.html | page or question, and record |
| Product description | Its live revision's layout, else products/product-descriptions/show.html | productDescription and record |
| Custom entity record | The layout of its custom entity type, the same for every record of the type | The type's identifier, such as store, and record |
| Book, unit | Always books/books/show.html or books/units/show.html; their layout is not used to choose the template | book or unit, and record |
| Product category description | Always products/category-descriptions/show.html | categoryDescription, with the category's products as products; there is no record |
A custom entity type with no layout template, or whose records are not set to have their own URL, answers 404 for its record URLs rather than falling back to anything. Books and units still have layouts and areas, which the template reads; a site that needs two looks for its books tells them apart inside the one template, from the layout's name or a layout area.
When there is no layout
A record without a layout, and every screen that is not a record (the sign-in page, search results, the cart), renders the controller's own template. Unless the controller names one, it is built from the module, the entity and the action, in lower case with hyphens and with no frontend/ segment: pages/pages/show.html, blogs/posts/show.html. The platform ships none of the content ones, so these files are part of every theme (No frontend segment).
Two records of the same type, two templates
Two pages of one site can render with completely different templates, because each carries its own layout. Asking the API for both shows it: