Layouts
Blogin renders pages with Template::HAML.
A build wraps each post's rendered body in show.haml inside base.haml, and each
section listing in index.haml inside base.haml.
The layout files#
| File | Role |
|---|---|
base.haml |
Page shell, wraps everything. Required. |
show.haml |
A single post. Required. |
index.haml |
A section or tag listing. Required for listings. |
home.haml |
The site root. Optional, falls back to index.haml. |
_header.haml, _sidebar.haml, _footer.haml |
Optional chrome, pulled in by base.haml. |
_nav.haml, _search.haml |
The nav menu and search form partials. |
An absent chrome partial is skipped rather than an error, so a site without a
sidebar renders full width. A missing base.haml, show.haml, or index.haml
is a build error that names the layout.
The home page#
The site root renders through home.haml when it exists, falling back to
index.haml. This gives the root a distinct landing page, a hero and feature
callouts, separate from the home-section listing that the same posts produce at
their section path. Like a listing, home.haml can reach posts and
pagination-html, or ignore them for a static landing.
Per-section layouts#
A section overrides a layout by placing it in a matching subdirectory. A post in
content/essays/ renders through layouts/essays/show.haml when present,
otherwise layouts/show.haml, resolved by the nearest ancestor. The same applies
to index.haml and the chrome partials.
What a template can reach#
Templates read post fields and site data as bare identifiers: title, date,
body, site-title, section. A single post exposes body (the rendered HTML,
injected unescaped) and post-nav-html, links to the newer and older posts in the
same section. A listing exposes posts and pagination-html. The nav tree is
available as nav-nodes, with nav-current(node) marking the current section.