Templates

How squiggly templates render content into HTML.

Templates live under layouts/ and are written in squiggly, a Go-template-style language. Every template is plain HTML with {{ ... }} interpolation.

Template kinds

KindFilename patternWhen it’s used
baseof_default/baseof.htmlOuter shell — wraps every page
file_default/file.htmlSingle-page template
folder_default/folder.htmlSection-index template
Partialpartials/<name>.htmlCalled via {{ partial 'name' . }}
Shortcodeshortcodes/<name>.htmlCalled from markdown via [= name =]

The _default/ folder name comes from the defaultLayout config key. You can also place per-section overrides in layouts/<section>/ — juicer falls back to _default/ when a section-specific layout is missing.

The two-pass render

When both a particular template (file.html or folder.html) AND a baseof.html exist:

First pass — the particular template runs

Its output is discarded. What matters are the {{ define <name> }}…{{ end }} blocks it populates.

Second pass — baseof.html runs

Its {{ block <name> . }}…{{ end }} calls pull the previously-defined content into place.

This pattern lets a single baseof.html provide the entire page chrome (head, header, sidebar, footer) while file.html and folder.html only describe what goes in the main column.

<!DOCTYPE html>
<html>
<head><title>{{ .page.title }}</title></head>
<body>
  {{ partial 'topbar' . }}
  <main>
    {{ block main . }}{{ .content }}{{ end }}
  </main>
</body>
</html>
{{ define main }}
  <article class="prose">
    <h1>{{ .page.title }}</h1>
    {{ .content }}
  </article>
{{ end }}
{{ define main }}
  <article class="prose">
    <h1>{{ .page.title }}</h1>
    {{ .content }}
  </article>

<ul> {{ for p <- .section.pages }} <li><a href=”{{ p.url }}”>{{ p.title }}</a></li> {{ end }} </ul> {{ end }}

The data context

Every page renders against a fixed data context:

VariableWhat it holds
.siteSite config + pages, pagesByPath, root
.pageThe current page record (frontmatter + url + summary + nav fields)
.sectionEnclosing section’s pages + subsections + index
.contentRendered markdown body
.tocHeading tree
.subFirst heading’s children, flattened

Inside .page:

  • .page.title, .page.summary — from frontmatter (summary is auto-derived if absent)
  • .page.url, .page.relPermalink, .page.permalink — three URL flavors
  • .page.parent, .page.ancestors — section navigation
  • .page.next, .page.prev — sibling navigation
  • .page.isSectiontrue for _index.md pages
  • Plus any custom frontmatter key

See Reference / Template data for the full set.