yaml
Sets the YAML parser
Kirby reads blueprints and the YAML in your content files, e.g. of structure or object fields, with the Symfony YAML parser. It closely follows the YAML specification. Some notations that more forgiving parsers accept are errors, e.g. tabs for indentation or unquoted values that start with @.
Writing valid YAML
If Kirby cannot parse a YAML file, the error message tells you the line of the first problem, e.g.:
The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar at line 4 (near "placeholder: @yourhandle").
Page and file blueprints with a YAML error silently fall back to the default blueprint. If the fields of a page or file are suddenly gone, check its blueprint.
Watch out for these cases in your blueprints:
- Wrap values in quotes if they start with a character that has a special meaning in YAML, e.g.
@,%,`,[or{. This includes query templates like"{{ page.title }}". - Use single quotes for values with backslashes, e.g. regular expressions. Inside double quotes, a backslash starts an escape sequence.
- Quote the entire value if it starts with a quoted part, e.g.
label: '"Hello" world'. - Indent with spaces only.
- Don't define the same key twice on the same level.
fields:
twitter:
type: text
placeholder: "@yourhandle"
discount:
type: number
after: "%"
title:
type: text
label: "[Draft] Title"
byline:
type: info
text: "{{ page.title }} by {{ page.author }}"
zip:
type: text
pattern: '^\d{5}$'
Some unquoted values have a type of their own:
- Only
trueandfalseare booleans.yes,no,onandoffare strings, which count astruefor options that expect a boolean:required: nomakes a field required. - Unquoted dates like
2024-01-01or2024-01-01 10:30:00are converted to Unix timestamps. Quote dates to keep them as strings, e.g.min: "2024-01-01".
Spyc parser
If your blueprints or content can't be read by Symfony YAML yet, you can switch to the older Spyc parser in the meantime:
return [
'yaml.handler' => 'spyc'
];
The Spyc parser is deprecated and will be removed in a future major version.