Front matter
A page can start with a YAML front matter block delimited by --- on its own line at the very start of the file:
1---
2title: Installing
3weight: 2
4---
5
6Page content starts here.
A leading UTF-8 byte order mark is ignored. If the file has no front matter, --- is ordinary text. An opening --- with no closing --- is an error (frontmatter.yaml), and so is YAML that does not parse.
Fields
| Field | Type | Meaning |
|---|---|---|
title |
string | Page title for the navigation, <title> and the heading the layouts add. |
description |
string | Used for the <meta name="description"> tag; falls back to site.description. |
date |
date | Publication date, shown by the post layout and written to the sitemap as lastmod. |
draft |
bool | A draft is left out of a normal build and included in tryck dev. |
weight |
int | Ordering among siblings in the navigation; lower comes first. |
navTitle |
string | A shorter label for the sidebar and previous/next links. |
layout |
string | Layout name (file without .html); overrides defaults.layout. |
toc |
bool | Show the table of contents; when absent, defaults.toc applies. |
slug |
string | Replaces the last URL segment. |
aliases |
list of strings | Old URLs; each becomes a redirect page. |
A page's front matter is also available to templates through .Page, for example .Page.Title, .Page.Date, .Page.Aliases and .Page.Params.
Unknown keys
Keys that are not in the table above are kept as page parameters, not rejected. This is how you attach your own data to a page:
1---
2title: Widget
3toc: false
4status: beta
5reviewers:
6 - Ada
7 - Grace
8---
Use them in a custom layout as .Page.Params.status and .Page.Params.reviewers.
Drafts
A page with draft: true is:
- left out of
tryck buildunless you pass--draftsor setbuild.drafts: true, - included by
tryck dev, with a banner at the top of the page, - left out of the sitemap and the search index even when drafts are built.
Aliases and redirects
Each entry in aliases becomes a small HTML page that redirects to the page. An alias must start with /.
1---
2title: Installation
3aliases:
4 - /install/
5 - /setup.html
6---
/install/ is written to dist/install/index.html and /setup.html to dist/setup.html. An alias that does not start with / is an error (redirect.alias).