A schema is a predefined template that determines what should populate a collection file. You can configure several schemas for each collection, creating a list of file templates for you and your team.
This article covers all the keys available for schema configuration. To learn more about schemas, read our documentation on creating a schema.
Each entry in schemas
has the following options available:
The create path definition to control where new files are saved to inside this collection. Defaults to [relative_base_path]/{title|slugify}.md
.
Read more details for create
when choosing where to create new files.
Sets the behavior when editing existing files with inputs not present in the schema with remove_extra_inputs
set to false
. Defaults to false
. Has no effect if remove_extra_inputs
is true
.
If true
, non-schema inputs are hidden in the Data Editor.
If false
, non-schema inputs are visible in the Data Editor.
Displayed in the add menu when creating new files, also used as the icon for collection files if no other preview is found. Must be a Material Icon name. Defaults to notes
.
Displayed in the add menu when creating new files. Defaults to a formatted version of the key.
Preview your unbuilt pages (e.g. drafts) to another page’s output URL. The Visual Editor will load that set preview URL and use the Data Bindings and Previews to render your new page without saving.
For example new_preview_url: /about/
will load the /about/
URL on new or unbuilt pages in the Visual Editor.
The path to the schema file. Relative to the root folder of the site. Required.
Controls whether or not inputs are sorted to match the schema when editing existing files. Defaults to true
.
Non-schema inputs are ordered after schema inputs if not removed with remove_extra_inputs
.
Sets the behavior when saving files with empty inputs. Defaults to false
.
If true
, empty inputs are removed before persisting the data to the source file.
If false
, empty inputs are persisted in the source file.
Removed inputs are available for editing again provided they are in the matching schema file. Inputs are considered empty if the value is null
, undefined
or ''
.
Sets the behavior when editing existing files with inputs not present in the schema. Defaults to true
.
If true
, non-schema inputs are removed before the editor loads, and subsequently removed from the source file if saved.
If false
, non-schema inputs are either hidden or visible in the editor depending on hide_extra_inputs
, but still kept in the source file on save.
If any inputs conflict with schema (e.g. a file's title
is a string and the schema's title
is an object), the schema version takes priority.
The preview definition for changing the way collection items with this schema are previewed across the editor. Defaults to using the collection's preview
.
All preview options are available for schemas, and are the same as the ones listed in the collections configuration options:
gallery
icon
image
metadata
subtext
text
See the preview options documentation for detailed information on setting this option.
Schemas now support the new preview
option. Read our migration guide if you are still using the old options: text_key
, subtext_key
, image_key
and image_size
.