Statac

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:

  1. the template named by the page’s own layout:, as in layout: post;
  2. the template named by its type:, if templates/ has one;
  3. a layout: cascaded from its folder or from statac.yaml, as in pages.layout: post, unless the page is a list page;
  4. home for the home page, folder for any other list page, and page for 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.html or folder.html, Statac builds a list page you wrote with page.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 has templates/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/redirect.html 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.