Settings

In order to make it easier for merchants to customize themes, you can use JSON to create settings that are accessible through the theme editor.

Create settings

You can create settings in the following places:

settings_schema.json

The settings_schema.json file controls the content of the Theme settings area of the theme editor. Settings in this file translate to global theme settings, which can be accessed through the Liquid settings object.

Section schema

The section schema is where you can create section settings and block settings. Those settings can be accessed through the settings attribute of the section object and block object, respectively.

Setting types

There are two categories of settings:

  • Input settings - These can hold a value, and are configurable by merchants.
  • Sidebar settings - These can’t hold a value, and aren’t configurable. They’re informational elements that can be used to provide detail and clarity for your input settings.

Translate settings

You can translate various attributes of the settings schema depending on the online store's active language. These translations are stored in schema locale files.

Access settings

You can access settings through three different Liquid objects, depending on where they were created:

To access a specific setting, append the id attribute of the associated setting to the object that you want to access.

For example, if you had the following setting implemented in each Liquid object:

Then the following Liquid would generate the following output:

Value check

When referencing settings, you should always check that the value is in the format that you expect. Any setting without an automatic default value could end up with no value, which translates to an empty string.

For example, if you have a setting with an id of message, then the following Liquid would generate the following output depending on the value:

You can check whether a value is an empty string with the blank operator. For example:

Resource-based settings

To avoid an empty string, check that the value is in the format that you expect. It's possible that no resource was selected, selected resource no longer exists, or the selected resource has been hidden.

For example, if you have the following page type setting:

Then you can check for emptiness like the following:

Legacy resource-based settings

In the past, resource-based settings returned the handle of the associated resource, and you had to access the actual object through Liquid using that handle.

For example, if you had the following product setting, then you would need to access the product object like the following:

Dynamic sources

Settings for sections included in a JSON template will have the option for merchants to connect one or more dynamic sources to the setting, depending on the setting type. A dynamic source can be either:

  • A metafield value
  • A resource attribute

Available values

Shopify determines the value of each available dynamic source type based on the following:

  • The resource associated with the template that the section is in

  • The resource settings in the context of the current setting

For example:

How Shopify determines available values
Conditions Description
The section is included as part of the product template Metafields and attributes related to the product will be available for the following:
  • The section's settings
  • The settings for any block in the section
The section includes a product type setting Metafields and attributes related to the product will be available for the following:
  • The section's settings
  • The settings for any block in the section
The section's blocks include a product type setting Metafields and attributes for that product will be available for the block's settings.

The following table lists the available resources and their associated attributes:

Available resources and their attributes
Resource Attributes
product
  • title
  • vendor

The following outlines which setting and metafield types will be compatible:

Setting Metafield(s)
color
  • color
image_picker
  • file_reference
page
  • page_reference
product
  • product_reference
richtext
  • single_line_text_field
  • multi_line_text_field
  • number_integer
  • number_decimal
  • date
  • date_time
  • weight
  • volume
  • dimension
text
  • single_line_text_field
  • number_integer
  • number_decimal
  • date
  • date_time
  • weight
  • volume
  • dimension
url
  • url

Default values

You can configure a setting's default value to reference a dynamic source. However, only do this if you're rendering a section or block in a context where the dynamic source value exists. For example, don't use a product-related value in a section that:

  • Can be rendered in non-product templates

  • Doesn't explicitly have a product type setting to provide the necessary value

Additional Liquid is invalid when using this method, so you can only reference the value directly. If you include additional Liquid, then you'll get an error.

The following is an example of a default setting that references a dynamic source: