Which template builds a page
How Statac chooses the template that builds each page.
Statac builds a page with the first of these that applies:
- the template named by the page’s own
layout:, as inlayout: post; - the template named by its
type:, iftemplates/has one; - a
layout:cascaded from its folder or fromstatac.yaml, as inpages.layout: post, unless the page is a list page; homefor the home page,folderfor any other list page, andpagefor every other page.
List pages are a folder’s index.md, a tag’s or a series’ page, a page
with posts: or each:, and the paginated pages of each of these: see
list pages.
On a page with each:, layout: sets the template for the pages it
makes, not for the page itself: see
make a page for each item.
Without the template
- If the site has no
home.htmlorfolder.html, Statac builds a list page you wrote withpage.html. - If a page you wrote has no
layout:, of its own or cascaded, and the site has none of these templates for it, Statac publishes the page’s content alone, with no doctype and nothing round it. - A page Statac makes itself, such as a tag’s page or a page made by
each:, has no content of its own, so it needs its template. - If there is no
content/index.md, Statac makes a home page only if the site hastemplates/home.html.
A template’s name
A template’s name is its file name, with or without .html: post and
post.html both mean templates/post.html. A template for another kind
of file keeps its extension, as in layout: sitemap.xml. Statac escapes
the values it shows to suit that kind of file: as markup in HTML and
XML, as JSON values in .json, and not at all in .txt.
Templates Statac looks for by name
| Template | Builds |
|---|---|
templates/feed.xml | Each feed a list asks for. Statac builds a feed with the template named after its file, such as templates/rss.xml for rss.xml, if the site has one. If not, it uses the template named after the feed’s extension, such as templates/feed.json for /feed.json, and if there is none, templates/feed.xml. So a list that asks for several feeds can build each with a template of its own. |
templates/ | The small page Statac publishes at each old URL, and for each page with redirect_to. Without this template, Statac publishes a refresh to the new URL and a link to it. |
Something unclear or wrong? Open an issue.