Liquid templates

Liquid templates allow you to control the look and feel of different pages of the online store using sections.

Liquid templates are data files that store a list of sections to be rendered, and their associated settings. Merchants can add, remove, and reorder these sections using the theme editor.

When a page is rendered with a Liquid template, the sections are rendered in the order specified by the order attribute, with no markup between the sections.

Schema

Liquid templates must be valid JSON files. The root should be an object with the following attributes:

AttributeTypeRequiredDescription
content_for_pageArrayYesAn array of section IDs, listed in the order that they should be rendered. The IDs must exist in the section object. Duplicates are not allowed.
layoutStringNoThe filename of the layout to use when rendering the template. For example, specify "password" to render layout/password.liquid.

The default layout is theme.liquid.

Use the value false to render the template without a layout. Templates without a layout can't be customized in the theme editor.
sectionsObjectYesAn object that uses section IDs as keys, and section data as values. This attribute needs to contain at least one section.

Duplicate IDs within the template aren't allowed.

The format of the section data is the same as the section data in settings_data.json. To learn more, refer to Section data.

Section data

The sections attribute of Liquid templates holds the data for the sections to be rendered by the template. These can be either theme sections or app sections. You can't share section data across Liquid theme templates, so each section must have an ID that's unique within the template.

You can add sections to a template in code, or through the theme editor.

The following table outlines the format of the section data:

ValueTypeRequiredDescription
<SectionID>String-A unique ID for the section. Accepts only alphanumeric characters.
<SectionType>StringYesThe filename of the section file to render, without the extension.
<BlockType>StringYesThe type of block to render, as defined in the schema of the section file.
<SettingID>String-The ID of a setting is defined in the schema of the section or the block.
<SettingValue>(multiple)-A valid value for the setting.

For example:

{
  "sections": {
    "<SectionID>": {
      "type": "<SectionType>",
      "settings": {
        "<SettingID>": "<SettingValue>"
      },
      "blocks": [
        {
          "type": "<BlockType>",
          "settings": {
            "<SettingID>": "<SettingValue>"
          }
        }
      ]
    }
  }
}

For example, the following template renders the product_detail.liquid and product_description.liquid section files on product pages:

{
  "content_for_page": [
    "1539149753700",
    "1634491726560"
  ],
  "sections": {
    "1539149753700": {
      "type": "product_detail",
      "settings": {
        "mobile_gallery_layout": "slide_show",
        "show_thumb_mb": true
      }
    },
    "1634491726560": {
      "type": "product_description",
      "settings": {
        "open_full_page": false,
        "spacing": 20
      }
    }
  }
}

🚧

Caution

Any sections that are included in a template, and aren't app sections, must exist in the theme. If they don't, then this will result in an error.