Masthead Documentation

Objects

Group related fields into a single configurable value using objects. Objects make complex configuration easier to organize and consume from templates.

Objects allow multiple related fields to be grouped under a single value.

Instead of declaring several independent settings, objects make it possible to model structured data such as contact information, addresses or hero sections.

Declaring an object

Objects are declared like any other field by setting their type to object.

{
  "key": "hero",
  "label": "Hero",
  "type": "object",
  "fields": [
    {
      "key": "title",
      "label": "Title",
      "type": "string"
    },
    {
      "key": "subtitle",
      "label": "Subtitle",
      "type": "text"
    }
  ]
}

Every object contains a collection of child fields.

Like top-level fields, each child declares its own key, label and type.

Accessing an object

Objects are accessed using dot notation.

<h1>{{ page.metadata.hero.title }}</h1>
<p>{{ page.metadata.hero.subtitle }}</p>

Objects can be declared as both theme tokens and page metadata.

When to use objects

Objects are useful whenever several fields belong together.

Common examples include:

  • Hero sections
  • Contact information
  • SEO settings
  • Call-to-action blocks

Grouping related values makes both the editor and the template easier to understand.

Nesting

Objects can contain scalar fields only.

If you need a repeatable collection of objects, use a list instead.