Settings
To make it easier for editors to customize your theme, you can use JSON to create settings that editors can access via the Basker Studio.
You can provide settings at the theme, template, or block level. Settings can be fixed (such as informational elements) or interactive (such as a drop-down menu). Setting values can be static, or use dynamic sources to render contextually appropriate values.
Exposing settings makes your theme more customizable so it can better express a venue’s brand. It also can make your theme more flexible so that you can address various use cases for editors.
Location
Section titled “Location”You can create settings in the following places:
config
> settings_schema.json- Template files in the
templates
folder, using the template’s{% schema %}
tag. - Block files in the
blocks
folder, using the block’s{% schema %}
tag.
└── theme ├── config | ├── settings_schema.json | ... ├── templates | ├── event.liquid | ├── venue.liquid | ... └── blocks ├── well.liquid ├── review.liquid ...
Theme settings
Section titled “Theme settings”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.
{ "name": "social", "type": "group", "fields": [ { "type": "text", "name": "facebook_link", "label": "Facebook" } ]}
{% if settings.social.youtube_link %} <a href="{{ settings.social.facebook_link }}">Facebook</a>{% endif %}
Template settings
Section titled “Template settings”The template {% schema %}
tag is where you can create template settings. Those settings can be accessed through the settings attribute of the section object and block object, respectively.
{ "name": "event", "settings": [ { "type": "color", "label": "Event Header Color", "name": "event_header_color" } ]}
{% if theme.settings.event_header_color %} <div class="event-header" style="background: {{ theme.settings.event_header_color }}"></div>{% endif %}
Block settings
Section titled “Block settings”The block {% schema %}
tag is where you can create block settings. Those settings can be accessed through the settings attribute of the section object and block object, respectively.
{ "name": "well", "label": "Well Block", "settings": [ { "type": "text", "label": "Title", "name": "title" } ]}
{% if block.settings.title %} <h2>{{ block.settings.title }}</h2>{% endif %}
Schema
Section titled “Schema”Settings are defined as a JSON settings attribute that’s parented to the object that the settings apply to. This attribute accepts an array of settings.
{ ... "settings": [[ { "type": "text", "label": "Title", "name": "title" }, { "type": "richtext", "label": "Content", "name": "content" }, { "type": "checkbox", "label": "Center Title?", "name": "centered" } ], ...}
Access settings
Section titled “Access settings”Depending on where they were created, you can access settings through the following Liquid objects:
- The global
settings
object - The
template
object - The
block
object