Pick a layout per page in Stati

How Stati finds a page's layout, and the typo it won't tell you about.

SNP 057 #641 Filed stati eta

yaml
---
title: Home
layout: home
---

layout: home renders the page with site/home.eta. The name is relative to site/ and has no .eta: layout: layouts/post is site/layouts/post.eta.

Without a layout, Stati walks up from the page's folder and takes the first template it finds:

text
site/
├── layout.eta        everything else
├── home.eta          pages with layout: home
└── blog/
    ├── index.md
    ├── index.eta     blog/index.md, the listing
    ├── layout.eta    the posts
    └── hello.md
  • A layout that doesn't exist is ignored without a warning, and the page gets the usual layout.eta. When a page looks wrong, check the spelling first.
  • Index pages, which are the home page and a folder's index.md with pages next to it, look for index.eta before layout.eta in each folder. That's how a listing gets its own template while the posts keep theirs, and why a site/index.eta becomes the home page's layout.
  • A folder's layout.eta replaces the one above it rather than wrapping it. Every layout is a whole HTML document, so share the head, header and footer as partials.

In the Stati docs: Template resolution order and Layout inheritance.