Content presets are a means of empowering editors to work more productively by providing a starting point for new pages and components.

This means that when an editor chooses to start from a preset, Stackbit creates the content matching that preset.

Presets with Git CMS

When content is stored locally, content models have to be defined within the project. Because of this, Stackbit knows the difference between an embedded object and a reference.

For example, if a page has a field called components in which it held data for the components, the content for each item gets stored directly on the page.

# content/pages/

title: "Home Page"
  - type: "Button"
		label: "Click Me"
		href: "/"
# ...

If that same page also has an author, but that is a reference to another piece of content, then Stackbit knows how to store the reference.

# content/pages/
title: 'Home Page'
author: 'content/pages/author/'
# ...

Handling References in Contentful

Contentful operates differently. In Contentful, all relationships among objects are references.

Using the example above, Stackbit doesn’t know if the relationship between two models should be treated as though it is embedded (component example) or referenced (author example).

By default, Stackbit uses existing references for content from presets. Using the examples above, if you added a component and an author to a page created from a preset, Stackbit will use the existing component and author entries. The only new content created will be the page entry.

Visual representation of presetReferenceBehavior setting

You can override this behavior using the presetReferenceBehavior setting in stackbit.yaml. See below for examples.

Note that preset configuration changes only apply to newly-created presets. This is because preset configurations are stored as files and Stackbit will not adjust existing files in your repository.

Duplicating References

If you’d prefer the Stackbit duplicate references by default rather than using existing references, you can set that behavior in stackbit.yaml.

# stackbit.yaml

# ...
presetReferenceBehavior: 'duplicateContents'

Adding Models as Exceptions

There will likely be exceptions to that rule. Again using the example above, you may want buttons to be duplicated, but author references to be copied.

Specifying Exceptions to copyReference

In that case, we can leave the default presetReferenceBehavior set to copyReference and set the models which should duplicate the content instead (button).

# stackbit.yaml

# ...
  - button

Visual representation of duplicatableModels setting

Specifying Exceptions to duplicateContents

The option changes if you’ve overridden the default behavior. In that case, you’d use nonDuplicatableModels:

# stackbit.yaml

# ...
presetReferenceBehavior: duplicateContents
  - author

Visual representation of nonDuplicatableModels setting