Skip to content
On this page · 12 sections
  1. Global settings
  2. config/settings_schema.json
  3. config/settings_data.json
  4. Reading settings in Liquid
  5. Colour schemes
  6. Fonts
  7. Translations
  8. The t filter
  9. t: keys in schemas
  10. Missing keys
  11. Right-to-left languages
  12. Per-language content
Docs

Theme settings and translations

Updated

Define a theme's global settings, styles, colour schemes and fonts, translate its text and editor labels, and support right-to-left languages and per-language content.

A theme's global settings are the choices that apply everywhere: colours, fonts, spacing, social links. They appear under theme settings in the theme editor. Its translations are the theme's own words, such as "Search" or "Next page", in every language your website has. This page covers both.

Global settings

config/settings_schema.json

A list of groups. The first entry is theme_info; each group after it has a name and settings, which use the same setting types as sections.

[
  {
    "name": "theme_info",
    "theme_name": "My theme",
    "theme_version": "1.0.0",
    "theme_author": "Me",
    "theme_documentation_url": "#",
    "theme_support_url": "#",
    "theme_supports": { "form_condition_operators": 2, "menu_depth": 1 }
  },
  {
    "name": "t:settings_schema.look.name",
    "settings": [
      { "type": "font_picker", "id": "font", "label": "t:settings_schema.look.font", "default": "inter_n4" },
      { "type": "range", "id": "radius", "label": "t:settings_schema.look.radius", "min": 0, "max": 24, "step": 2, "unit": "px", "default": 8 }
    ]
  }
]

theme_supports tells the platform what your theme can do:

form_condition_operators number
Set it to 2 when your theme's form script handles every condition operator, as the Blank theme's snippets/form-fields.liquid does. Without it, form builders on your site are offered only the basic conditions (equals, does not equal, contains, is empty, is not empty).
menu_depth number, 1 to 5
How many levels of a menu your theme draws. The menu editor warns owners about links deeper than that, which your theme would never show.

config/settings_data.json

The values of the settings. current holds the values in use; presets holds your theme's styles.

{
  "current": {
    "font": "inter_n4",
    "radius": 8,
    "color_schemes": {
      "scheme-1": { "settings": { "background": "#ffffff", "text": "#111111" } }
    }
  },
  "presets": {
    "Soft": { "font": "inter_n4", "radius": 8, "color_schemes": { "scheme-1": { "settings": { "background": "#ffffff", "text": "#111111" } } } },
    "Sharp": { "font": "ibm_plex_mono_n4", "radius": 0, "color_schemes": { "scheme-1": { "settings": { "background": "#ffffff", "text": "#000000" } } } }
  }
}
  • A style lists only look settings (colours, colour schemes, fonts, ranges, numbers, selects, radios, checkboxes, text alignment), and every style lists the same ones, so switching style back and forth is lossless. Other settings, such as social links, belong in current only.
  • A theme can offer up to 5 styles. Keep names short (one or two words) and name one after the theme.
  • A changed setting in the editor is saved to current.

Reading settings in Liquid

Every setting is on settings by its id: {{ settings.radius }}px. A setting that has no value uses its schema default. Turning look settings into CSS variables in one snippet keeps your CSS simple, and the theme editor previews changes to a {% style %} block live:

{%- style -%}
  :root {
    --font: {{ settings.font.family }}, {{ settings.font.fallback_families }};
    --radius: {{ settings.radius }}px;
  }
{%- endstyle -%}

Colour schemes

A colour scheme is a named set of colours that a section or block applies by choosing it. Define the set once with a color_scheme_group setting in config/settings_schema.json:

{
  "type": "color_scheme_group",
  "id": "color_schemes",
  "definition": [
    { "type": "color", "id": "background", "label": "t:settings_schema.colors.background", "default": "#ffffff" },
    { "type": "color_background", "id": "background_gradient", "label": "t:settings_schema.colors.background_gradient" },
    { "type": "color", "id": "text", "label": "t:settings_schema.colors.text", "default": "#000000" },
    { "type": "color", "id": "accent", "label": "t:settings_schema.colors.accent", "default": "#2563eb" }
  ],
  "role": {
    "text": "text",
    "background": { "solid": "background", "gradient": "background_gradient" },
    "links": "accent",
    "icons": "text",
    "primary_button": "accent",
    "on_primary_button": "background",
    "primary_button_border": "accent",
    "secondary_button": "background",
    "on_secondary_button": "text",
    "secondary_button_border": "text"
  }
}
  • definition lists the colours every scheme has.
  • role says which colour plays which part, so the editor can draw a preview swatch for each scheme.
  • The schemes themselves (scheme-1, scheme-2, ...) and their values live in settings_data.json under color_schemes. Owners edit their colours in the theme editor, where the schemes are called "Scheme 1", "Scheme 2" and so on.

Print one CSS class per scheme, then give each section the class of the scheme it chose with a color_scheme setting:

{%- style -%}
  {% for scheme in settings.color_schemes %}
  .color-{{ scheme.id }} {
    --color-bg: {{ scheme.settings.background }};
    --color-fg: {{ scheme.settings.text }};
    --color-accent: {{ scheme.settings.accent }};
    background: {% if scheme.settings.background_gradient != blank %}{{ scheme.settings.background_gradient }}{% else %}{{ scheme.settings.background }}{% endif %};
    color: var(--color-fg);
  }
  {% endfor %}
{%- endstyle -%}

<section class="color-{{ section.settings.color_scheme }}" {{ section.in1s_attributes }}>…</section>

A colour also has red, green, blue, hue, saturation, lightness, alpha, rgb and rgba properties, and the colour filters work on it. A color_scheme setting with no value is the first scheme.

Fonts

A font_picker setting stores a font handle: the family, then _, then n (normal) or i (italic) and the weight in hundreds. inter_n4 is Inter, normal, 400; open_sans_i7 is Open Sans, italic, 700.

Built-in families: poppins, inter, roboto, open_sans, lato, montserrat, source_sans_pro, raleway, nunito, assistant, playfair_display, dm_sans, plus_jakarta_sans, manrope, outfit, ibm_plex_sans, jetbrains_mono and ibm_plex_mono (web fonts), and arial, helvetica, georgia, times_new_roman and verdana (system fonts, nothing to load).

Owners can also upload their own fonts (.woff2, .woff, .ttf, .otf). An uploaded font's handle starts with custom_, for example custom_my_brand_font_n4. The editor refuses a font that is neither built in nor uploaded to the website.

In Liquid a font setting is a font object with family (ready for CSS), weight, style, fallback_families, system? and variants. Load it with both font filters, which together cover every kind of font:

{%- assign font_url = settings.font | font_url -%}
{%- if font_url != blank -%}<link rel="stylesheet" href="{{ font_url | escape }}">{%- endif -%}
{%- style -%}
  {{ settings.font | font_face }}
  :root { --font: {{ settings.font.family }}, {{ settings.font.fallback_families }}; }
{%- endstyle -%}

Use font_modify for a bolder or italic face of the same family: {{ settings.font | font_modify: 'weight', 'bold' }}. Load fonts in layout/password.liquid too.

Translations

A theme has two kinds of locale files in locales/:

File Holds Used with
{lang}.default.json The theme's text, in the default language (one file, required) {{ 'general.search' | t }}
{lang}.default.schema.json Editor labels in the default language (required) "label": "t:sections.hero.settings.heading.label"
{lang}.json The theme's text in another language
{lang}.schema.json Editor labels in another language

{lang} is a language code such as en, ar or pt-BR.

The t filter

{
  "general": {
    "search": "Search",
    "page": "Page {{ number }}",
    "results": { "one": "{{ count }} result", "other": "{{ count }} results" },
    "note_html": "Read the <a href=\"/terms\">terms</a>."
  }
}
{{ 'general.search' | t }}
{{ 'general.page' | t: number: paginate.current_page }}
{{ 'general.results' | t: count: search.results_count }}
{{ 'general.note_html' | t }}
  • Parameters fill the {{ name }} placeholders in the text.
  • With count, a key holding plural forms picks the form the visitor's language needs (one and other in English; other languages use forms such as zero, two, few and many), falling back to other.
  • Output is escaped, except for keys ending in _html.
  • In the theme editor, owners can click translated text on the page and change it.

t: keys in schemas

Every name, label, info, option label, content and preset name in a schema can be a t: key, looked up in the schema locale files. Shared labels conventionally go under sections.all; section labels under sections.<section-name>; theme block labels under blocks.<block-name>; global settings under settings_schema.

Missing keys

A key missing from a language file falls back to the default language file, silently. The code editor warns about a language file that is missing keys, and about a | t or t: key that the default file does not have. Keep the default files complete, and other languages as complete as you can.

Right-to-left languages

request.locale.text_direction is rtl for right-to-left languages such as Arabic, Hebrew, Persian and Urdu, and ltr otherwise. Print it on <html> in every layout, including layout/password.liquid:

<html lang="{{ request.locale.iso_code | default: 'en' }}" dir="{{ request.locale.text_direction | default: 'ltr' }}">

Then write direction-neutral CSS: margin-inline-start instead of margin-left, text-align: start instead of left, and so on, so the layout mirrors by itself. A text_alignment setting gives left, center or right; map left to start and right to end if it should follow the reading direction:

{%- assign alignment = section.settings.alignment | replace: 'left', 'start' | replace: 'right', 'end' -%}

Per-language content

Your website's languages apply to your theme's content too. Text settings (text, textarea, richtext and inline_richtext) can hold a value per language: the owner switches language in the theme editor and types the other version. In a template, section group or settings file such a value is written as a map:

"heading": { "l10n": true, "en": "Welcome", "ar": "أهلاً بك" }

Liquid gives you the text in the visitor's language: {{ section.settings.heading }} prints "Welcome" on the English page and "أهلاً بك" on the Arabic one. A theme can ship its presets this way, so a new website is translated from the start; the Blank theme does this for English and Arabic.

Start typing to search the docs.