Tinacms Developer Docs

Templates

Define multiple structured variants within a single collection or object field

Templates allow you to define multiple structured variants within a single collection or object. They're ideal when you need different data shapes under the same parent.

For example, in a "page" collection there might be a need for a marketing page template and a content page template, both under the collection "page".

Examples

Basic example with two templates

export default defineConfig({
  //...
  schema: {
    collections: [
      {
        name: 'page',
        label: 'A page of the website',
        path: 'content/pages',
        format: 'mdx',
        templates: [
          {
            name: 'content',
            label: 'Content Page',
            fields: [
              // ... content page fields
            ],
          },
          {
            name: 'marketing',
            label: 'Marketing Page',
            inline: true,
            fields: [
              // ... marketing page fields
            ],
          },
        ],
      },
    ],
  },
})

Tina uses folder names matching the template to organize files correctly, e.g.:

/content/pages/marketing/home.md
/content/pages/content/about.md

Limitations

  • Collections using templates cannot use the 'Add Folder' button
  • Must provide only one of fields or templates on a collection — not both

On this page