Content Models map your themes content and data to a structured schema. Content models are defined in the stackbit.yaml inside the models key.

# stackbit.yaml

stackbitVersion: ~0.2.0
ssgName: custom
...
models: # top level models key
  article: # a page model called "article" 
    type: page # the content model type, can be: page, data, object
    label: Article
    folder: articles
    fields: # array of field models, must be nested under a content model
      - type: string
        name: title
        label: Title
  config: # a data model called "config"
    type: data
    label: Config
    file: config.yaml
    singleInstance: true
    fields: # array of field models, must be nested under a content model
      - type: string
        name: title
        label: Sites Title
            - type: baseurl
                name: BaseURL
                label: Sites BaseURL
            - type: image
                name: logo
                label: Path to Logo Image

Content Model Types

Page Models

A set of settings and fields defining the content structure of a specific page type rendered using a specific layout. For example, the "home" page model might define the content structure of a site's home page with all its sections. While the "article" page model could define the content structure of a blog post.

Data Models

A set of settings and fields defining the content structure of a data source other than site pages. For example, "header" and "footer" data models might define the content structure of a site's header.yml and footer.json data files.

Field Models

Field models are nested inside Page, Data and Object models and define individual fields.

Object Models

A model that defines content structure of an arbitrary object. This model might be reused by being referenced by another object model, data model or page model. For example, a site's home page might have multiple sections, where the content model of each section is defined by a separate Object Model. Another example is an object model defining commonly used UI components such as an action button with predefined properties (label, url, color, etc.).

Common Content Model Fields

type

The type of the model.

  • Example value: "page"
  • Allowed values: page, data, object
  • Required: true

label

The label of the model. In some CMS, used as a menu item title of list of objects of this model.

  • Example value: "Blog Post"
  • Allowed values: string
  • Required: true

description

Description of the model. In some CMS, the description is shown besides models in model lists.

  • Example value: "Blog Posts"
  • Allowed values: string
  • Required: true

fields

The field models attached to the content model.

  • Example value: "Blog Posts"
  • Allowed values: List of Field Models (list of objects)
  • Required: true

Content Models Naming Rules

  • Must start with and end with a lower case letter
  • Can contain only lower case alphanumeric characters and an underscore _