Template functions · Pages

page

Generate a page from a template file, once per slug.

page "source" "slug"

Renders the source file (a path under src/) at <its URL>/<slug> and returns that URL. Inside the generated page, .Path holds the slug, which you use to look up the item to show.

A source that uses .Path after a space, as in {{ .Path }}, is a generator: it's only built through page, never on its own. Set path: in its frontmatter to choose the URL prefix. The function pages on this site are generated this way from data/functions.json.

Example

{{/* src/team.html */}}
{{ range data "team.json" }}
  <a href="{{ page "team/member.html" .slug }}">{{ .name }}</a>
{{ end }}

{{/* src/team/member.html, rendered at /team/member/<slug> */}}
{{ $slug := .Path }}
{{ range data "team.json" }}{{ if eq .slug $slug }}
  <h1>{{ .name }}</h1>
{{ end }}{{ end }}

data sources sort filter limit offset select paginate pages path hash json contains html js css

Edit this page · Last updated 2026-11-20