Page models are derived from page layouts - for each layout in the layouts folder (except body.html), there should be at least one page model with the following fields (two different page models might use the same layout):
type: the type of page model is always
page. This field is required.
label: A short, descriptive name for the page model. For example if you were creating a page model for blog content you might use the label "Blog" but you could also use "Article". This field is required. The label is often displayed in various CMS when viewing the lists of folders or "Content Types".
description: description of the model. A longer, more descriptive sentence about the page model. For example: "Article is used to write blog posts and appears under the Blog section"
layout: the filename of a page's layout (without the filename extension). For example, for
home.html the value should be
home. Every markdown page must define the
layout field (or the field defined in
pageLayoutKey) in its front matter, and its value must be equal to the value set here.
singleInstance: Can be set too
true for layouts that should have only one page instance (e.g.: home), and
false for layouts that can be used by several pages (page.html or post.html).
file: this field is required if
singleInstance: true and is used to specify the file path of the page file relative to the
folder: a folder, relative to the
content folder, with markdown files matching this page model. The default value is an empty string, meaning all files in the content folder. This field is mutually exclusive with
singleInstance: true. For example, for a site with posts located inside a "posts" folder, the "post" model should have this value set to
match: a glob pattern used to match markdown files inside the specified
folder. Defaults to all files. Internally the "micromatch" NPM module is used to match the files. This field is mutually exclusive with
exclude: a glob pattern used to exclude markdown files inside the specified
folder. Defaults to not exclude any files. Internally "micromatch" npm module is used to match the files. This field is mutually exclusive with
hideContent: should be set to
true for page models that do not have markdown content (e.g. home.html), and
false for page models that can have a markdown content (e.g.: page,html or post.html)
fields: a list of Field Models. Do not include
menus, as they will be added automatically by the conversion process.
Modeling an "article" page in the articles folder
Let's say you have some content written in markdown with the following front matter. Depending on your SSG the content might be located in a different folder.
--- title: How to install Node.js layout: article image_thumbnail: images/screenshot.jpg show_image: true --- # Et perhorruit quoque revocataque vellem ## Angue poma dentibus Aridus nostra abstractus viris vitataque labores hiatus ultima, favistis Hippothousque vincemus cum, nymphae [triformis aera quae](http://aether-diurnos.io/tamen.aspx) templa.
To create a content type with individual fields that a CMS can understand we need to define it as a page model in the
stackbit.yaml (note: the
layout is not defined among other front-matter fields but as a property of the model itself):
models: article: type: page # the content model type, can be: page, config, data, object label: Article layout: article folder: articles fields: - type: string name: title label: Title description: The title of the page. required: true - type: string name: image_thumbnail label: Image description: the articles image - type: boolean name: show_image label: Show Image description: Show or hide the image