Skip to content

Settings

You can use section JSON schemas to create settings, allowing sellers to customize your theme with little to no technical experience.

These settings can be defined on sections, blocks, or on the theme itself.

Types

There are two main types of settings:

  • Input settings - Settings that can hold a value and are configurable by merchants.

  • Display settings - These are static values with which you can provide context about parts of your theme to the seller.

Location

Settings can exist in one of two places:

  • sections/*.liquid - Can be defined on the section's {% schema %} tag. These can either be section settings or block settings, accessible from the section and block objects respectvely.

  • config/settings_schema.json - Can be defined at the theme level. These can be accessed from the global settings object.

Schema

Settings can be defined as an array of setting schema objects as a settings attribute on the appropriate object.

json
{
  ...
  "settings": [
    {
      "type": "header",
      "content": "Product settings"
    },
    {
      "id": "product_1",
      "type": "text",
      "label": "Product identifier",
      "info": "Select a product id to display"
    }
  ],
  ...
}

Access

Settings can be accessed by referencing the appropriate liquid object, this can be one of the following:

  • The section object.
  • The block object.
  • The global settings object.

For example, if you have your settings as is shown above on each of these liquid object, you may access them as follows:

liquid
// settings
Product identifier: {{ settings.product_1 }}

// section
Product identifier: {{ section.settings.product_1 }}

// block
Product identifier: {{ block.settings.product_1 }}

Checking for a setting's value

You should always check a setting's value before using it, blank or nil values are converted into an empty string when referecend.

When referencing a simple setting, you may check whether or not it is an empty string by comparing it to the liquid blank object.

liquid
 {%- if section.settings.product_1 != blank -%}
  {{ section.settings.product_1 }}
 {%- endif -%}