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:
- The global settings object
- The section object
- The block object
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:
{
"type": "text",
"id": "message",
"label": "Message",
"default": "Hello!"
}
Then the following Liquid would generate the following output:
// Settings
Message: {{ settings.message }}
// Section
Message: {{ section.settings.message }}
// Block
Message: {{ block.settings.message }}
// Settings
Message: Hello!
// Section
Message: Hello!
// Block
Message: Hello!
Updated over 3 years ago