Open navClose nav

Front Matter Templates


This guide assumes you already have an understanding of Front Matter and how it works with Forestry. If this isn’t the case, you can read up on it in the Front Matter doc.

What are Front Matter Templates?

Front Matter Templates (FMTs) enable developers to fully customize the interface of the Markdown and HTML editors. You can think of them as the content model for your front matter.

FMTs work by allowing developers to define which Front Matter Fields are available to editors when editing pages or content types.

Managing FMTs

FMTs can be creating using the CMS, or by creating Config Files.

FMTs can only be accessed in the CMS by team members with the Developer or Site Owner role.

Creating an FMT

FMTs can be created from scratch, or can be created using the fields from an existing page that doesn’t have an FMT applied to it.

Creating an FMT from Existing Pages

To create an FMT from an an existing page, navigate to the page you wish to use as the basis for your FMT.,dpr_auto,f_auto,q_80,w_640/, click the “…” button in the toolbar, then click Create Template.,dpr_auto,f_auto,q_80,w_640/

In the modal that opens, click Create Template. This will create the new template and redirect you to the Front Matter Template editor.

When creating an FMT from an existing page, the FMT will be named after the page. Make sure you rename it if that’s not the name you desire!

Creating an FMT from Scratch

To create a Front Matter Template from scratch, navigate to the Front Matter page, and click Add Template.,dpr_auto,f_auto,q_80,w_640/

You will now be redirected to the FMT editor. Enter a name for your new FMT, and then click Save Changes.

Editing FMTs

To edit an FMT, navigate to the Front Matter page in the CMS, and click the FMT you wish to edit from the list.,dpr_auto,f_auto,q_80,w_640/ the left, you’ll see a preview of how your FMT will look in the editors, and on the right you’ll see the list of available field types.

Adding a Field

To add a field, click the Add button under the field type you’d like to add. This will add the field to the bottom of your FMT.

The field editor will open for the new field, and prompt you to configure the field. All fields share some common options:

  • Label: the human-friendly label shown above the input field in the editor.
  • Name: the key stored in your content’s front matter. It is used to access this field in your templates.
  • Description: (Optional) a human friendly description of what the field does and/or instructions for your editors.

See the field documentation for a list of all options available for each field.

Editing a Field

To edit a field already added to your FMT, click the cog icon to the right of the field in the left pane.

Reordering Fields

Fields can be reordered by clicking the up and down arrows to the left of a field.

Removing a Field

To remove a field from your FMT, click the trash icon to the right of the field in the left pane.

Accidentally removed a field from your FMT? Fear not! All changes to FMTs are committed to your Git repository, and can easily be reversed by a developer!

Field Defaults

Default values for FMTs can be added. These defaults are applied when creating a new page in Forestry.

Field defaults are only applied when creating new pages and aren’t intended to be used as a fallback value for when no value is provided. For this, see How do I set fallback/hidden values for Front Matter?

Hidden Fields

Any field in an FMT can be hidden. This hides the field in the editors, but allows developers to set default values or maintain the field for legacy purposes.

This can be used to set default values when creating new pages for fields that shouldn’t be modified by an editor.

Applying FMTs to Content

FMTs can be applied to individual pages, or to content types.

FMTs follow a “no-modification” rule. When applying an FMT to content, Forestry will not modify any existing values, and it will not remove values that are not part of the FMT.

Applying to Pages,dpr_auto,f_auto,q_80,w_640/ apply an FMT to an individual page, navigate to the page you want to apply the FMT to and click the Settings button, and then select Change Template.,dpr_auto,f_auto,q_80,w_640/ the modal that opens, select the FMT you wish to apply to the page from the dropdown, and then click close.

Applying to Content Types

FMTs can be applied to all pages in a content type using the settings.yml config file. See the Config Files documentation for more information.

Applying an FMT to a content type will apply the FMT to any page without an FMT already applied to it. It will also make that FMT the default option when creating new pages.

Last updated on December 31, 2017