Developer docs

Theme code editor.

Write your own sections in Liquid, style your store with CSS and add behaviour with JavaScript. Everything you build shows up in the theme customizer.

Overview

The theme code editor lets you change your live theme as code, the way Shopify's code editor does. You can restyle your store with CSS, add behaviour with JavaScript, add tags to every page, and, most powerful of all, write your own sections in Liquid. A section you write appears in Customize → Add section next to the built-in ones, with its own settings, so you or your team can place it, edit it and reorder it without touching code again.

Open it from Online store → Themes: the live theme's ⋯ menu → Edit code. Changes are saved to your live theme the moment you save a file, and every save keeps a version you can restore.

Build a section

Markup, styles, script and settings in one .flys file.

Quick start →
Style your store

Override any rule of the theme in custom.css.

Styling →
Add behaviour

Run JavaScript when a section appears.

JavaScript →
Look things up

Every object, filter and setting type.

Reference →
Who can use it. Store owners and admins (not staff). The platform owner can switch the code editor on or off for each plan or each store.

Quick start: your first section

This takes about five minutes and shows the whole loop: write, preview, save, place, edit.

  1. Open the editor. Online store → Themes → the live theme's ⋯ menu → Edit code.
  2. Create a section. In the file list, press + next to Sections. Name it (for example Hero banner), choose a starter, and press Create. The file sections/hero-banner.flys opens.
  3. Preview it. Press Preview in the editor toolbar. You see the section with its default settings, using your live theme's colours and fonts. Switch between Desktop and Mobile widths.
  4. Change something. For example, change the default heading in the {% schema %} at the bottom, or edit the markup. Press Ctrl+S (or Save). If there is a mistake, the editor tells you what and where, and nothing is saved until it is fixed.
  5. Place it. Go back to Themes → Customize, press Add section and pick your section (it has a Custom tag). Its settings appear in the side panel and the preview updates as you type.
  6. Publish. Press Save in the customizer. Your section is live.
Tip. Start from a starter and change it. The starters (Hero banner, Image with text, Feature grid, FAQ accordion, Testimonials, Collection product grid) are complete, working examples of everything in this guide.

Files in the editor

The file list on the left shows everything that makes up your live theme.

FileWhat it isYou can
config/theme.jsonAll settings of the live theme: colours, fonts, header, footer, the home page sections and page templates. The same data the customizer edits.Edit (validated on save)
sections/<name>.flysA custom section: markup, styles, script and settings schema.Create, edit, delete
snippets/<name>.flysA reusable piece of Liquid you include from sections with render.Create, edit, delete
assets/custom.cssCSS added to every storefront page, after the theme styles.Edit
assets/custom.jsJavaScript that runs on every storefront page.Edit
layout/head.htmlExtra tags inside <head>: fonts, meta tags, verification tags.Edit
layout/body-end.htmlExtra markup just before </body>: widgets, pixels.Edit
layout/theme.htmlassets/theme.css, assets/theme.js: the platform's own theme code, shared by every store. Shown so you can read how things work.Read only

Limits

  • Each file can be up to 200 KB.
  • Up to 30 sections and 40 snippets per store.
  • Names use lowercase letters, numbers and hyphens (feature-grid).
  • The last 12 versions of each file are kept. Use History to compare, load or restore one.

Editor shortcuts

ShortcutAction
Ctrl/⌘ + SSave all changed files
Ctrl/⌘ + FSearch in the file
Ctrl/⌘ + GGo to line
Ctrl/⌘ + /Comment or uncomment the selection
Tab / Shift + TabIndent or outdent

The status bar shows the cursor position and file size. A dot on a tab or file means unsaved changes. Unsaved edits are kept if you leave the editor and come back.

The platform's own code is read-only on purpose. It is shared by every store, so changing it would change all of them. To change how your store looks or behaves, write overrides in custom.css and custom.js, or build your own sections.

Anatomy of a section file

Section and snippet files use the .flys extension. A .flys file is plain text: HTML mixed with Liquid-style tags, in the same syntax as Shopify's Liquid. One file, up to four parts. Only the markup and the {% schema %} are required for the section to show up in the customizer.

<section class="sec pad">
  <div class="wrap">
    <h2>{{ section.settings.heading }}</h2>
    {% for block in section.blocks %}
      <p class="note-line">{{ block.settings.text }}</p>
    {% endfor %}
  </div>
</section>

{% stylesheet %}
  .note-line { opacity: .8; }
{% endstylesheet %}

{% javascript %}
  document.addEventListener('fw:section:load', function (e) {
    if (e.detail.type !== 'announcements') return;
    console.log('Section ready', e.detail.el);
  });
{% endjavascript %}

{% schema %}
{
  "name": "Announcements",
  "settings": [
    { "type": "text", "id": "heading", "label": "Heading", "default": "News" }
  ],
  "blocks": [
    { "type": "note", "name": "Note", "settings": [
      { "type": "text", "id": "text", "label": "Text", "default": "Something new" }
    ] }
  ],
  "presets": [{ "name": "Announcements" }]
}
{% endschema %}
PartWhat it does
MarkupEverything outside the special blocks. Plain HTML mixed with Liquid: {{ }} prints a value, {% %} runs logic. This is what visitors see.
{% stylesheet %}CSS for the section. Added to the page once, no matter how many copies of the section are used. Use section.id in your markup if you need to style one copy differently.
{% javascript %}JavaScript for the section. Runs once per page load, wrapped so an error in it cannot break the page. See JavaScript.
{% schema %}JSON that describes the section: its name, the settings merchants can change, and the blocks they can add. See Schema reference.

The wrapper

Your markup is wrapped for you, so you never write the outer element:

<div class="fw-section fw-section-announcements" id="fw-sec-sec_abc123" data-sec="sec_abc123" data-section-type="announcements">
  ...your markup...
</div>

The wrapper lets the customizer highlight and select the section. To add your own class to it, set "class" in the schema.

When a section has a problem

  • On save: a Liquid syntax error or an invalid schema is shown in the editor and the file is not saved.
  • While rendering: if something fails at runtime (for example a filter used the wrong way), that section is skipped on the live store and the rest of the page still loads. In the customizer preview you see a red box with the message.

Schema reference

The schema tells the customizer what to show in the side panel. It is JSON in the same format Shopify uses, so most Shopify schemas work as they are.

{% schema %}
{
  "name": "Feature grid",
  "class": "my-features",
  "settings": [
    { "type": "header", "content": "Content" },
    { "type": "text", "id": "heading", "label": "Heading", "default": "Why shop with us", "info": "Shown above the grid" },
    { "type": "range", "id": "columns", "label": "Columns", "min": 2, "max": 4, "step": 1, "default": 3 },
    { "type": "select", "id": "align", "label": "Alignment",
      "options": [ { "value": "left", "label": "Left" }, { "value": "center", "label": "Centre" } ], "default": "left" },
    { "type": "checkbox", "id": "show_icons", "label": "Show icons", "default": true },
    { "type": "color", "id": "tint", "label": "Tint", "default": "#f5f5f5" },
    { "type": "image_picker", "id": "photo", "label": "Photo" },
    { "type": "url", "id": "link", "label": "Link" },
    { "type": "collection", "id": "collection", "label": "Collection" }
  ],
  "blocks": [
    {
      "type": "feature",
      "name": "Feature",
      "settings": [
        { "type": "text", "id": "title", "label": "Title", "default": "Fast delivery" },
        { "type": "textarea", "id": "text", "label": "Text" }
      ]
    }
  ],
  "max_blocks": 8,
  "presets": [
    { "name": "Feature grid",
      "settings": { "columns": 3 },
      "blocks": [ { "type": "feature", "settings": { "title": "Fast delivery" } } ] }
  ]
}
{% endschema %}

Top-level keys

KeyRequiredMeaning
nameYesThe title merchants see in Add section and in the section list. Up to 40 characters.
settingsNoThe list of settings merchants can change (up to 40). See the types below.
blocksNoRepeatable items inside the section, such as slides, questions or features (up to 12 block types).
max_blocksNoHow many blocks one section may hold. Default 16, maximum 30.
presetsNoThe first preset gives the default values and the starting blocks a new copy of the section gets.
classNoAn extra class added to the section wrapper.

Setting attributes

AttributeMeaning
typeOne of the types below.
idThe name you use in Liquid: section.settings.<id>. Letters, numbers and underscores, starting with a letter. Must be unique in its section.
labelThe field label merchants see.
defaultThe starting value.
infoA short help text under the field.

The ids blocks (in a section) and type (in a block) are reserved.

Setting types

TypeMerchant seesIn Liquid you getNotes
textA one-line fieldA stringmaxlength up to 500 (default 200).
textareaA multi-line fieldA stringUse | newline_to_br to keep line breaks. maxlength up to 4000.
richtextA multi-line fieldA stringPlain text. HTML is shown as text for safety.
numberA one-line fieldA string of digitsDo maths with | plus: 0 to turn it into a number.
checkboxA switchtrue or false
selectA drop-down (or buttons)The chosen option's valueNeeds options: a list of {{ "value", "label" }}. The default must be one of them, otherwise the first is used.
radioSame as selectSame as select
rangeA sliderA numberNeeds min, max (larger than min) and optional step and unit.
colorA colour pickerA hex string like #1a1a1aThe default must be a 6-digit hex colour.
image_pickerSelect image (from the Files library)An image address, or emptyPrint it with | img_url. Check != blank first.
urlA one-line fieldA stringAddresses starting with javascript: are removed.
collectionA collection drop-downA collection handle, or emptyUse it as collections[section.settings.collection]. Empty means all products.
link_listA menu drop-downA menu handle, or emptyUse it as linklists[section.settings.menu].
headerA bold heading in the panelNothingGroups settings. Use "content" for the text.
paragraphA line of help text in the panelNothingUse "content" for the text.

Other Shopify types (font_picker, product, page, video and so on) are not available. If you use one, the editor tells you which setting is the problem.

Blocks

Blocks are repeatable items. Merchants add, remove and reorder them in the customizer; you loop over them in your markup:

{% for block in section.blocks %}
  {% if block.type == 'feature' %}
    <div id="{{ block.id }}">
      <h3>{{ block.settings.title }}</h3>
      <p>{{ block.settings.text }}</p>
    </div>
  {% endif %}
{% endfor %}

Each block has block.id (unique), block.type (the type you defined) and block.settings. A section can have several block types; check block.type to render each one differently.

Liquid basics

Liquid is a small template language. You mix it with HTML to print values and make decisions. Sections here use the open-source LiquidJS engine, which follows Shopify's Liquid closely.

Output and logic

{{ product.title }}                      {% comment %} print a value {% endcomment %}
{{ product.price | money }}              {% comment %} filters change a value {% endcomment %}

{% if product.available %}In stock{% else %}Sold out{% endif %}

{% for product in collection.products limit: 4 %}
  {{ forloop.index }}. {{ product.title }}
{% else %}
  No products yet.
{% endfor %}

{% assign handle = section.settings.collection | default: 'all' %}
{% capture label %}{{ shop.name }} · {{ product.title }}{% endcapture %}

All standard tags are available: if, unless, case, for (with limit, offset, reversed and forloop), assign, capture, comment, raw, liquid, echo, cycle, tablerow, render and include.

Escaping and safety

Every value that reaches your template is already HTML-escaped: merchant settings, product names, page titles, menu labels and so on. A stray < or quote can never break your markup or inject code. You can still write | escape as you would on Shopify; it never escapes twice. Page content is the one exception: it is cleaned HTML and is meant to be printed as it is.

Not supported

  • {% section %}, {% sections %}, {% layout %}, {% form %}, {% paginate %} (Shopify-only tags).
  • Translation filters (| t), asset_url, content_for_header.
  • Reading or changing the cart or checkout from Liquid. Do that with JavaScript on the page.

Objects reference

These are the values available in every section and snippet.

section

PropertyMeaning
section.idA unique id for this copy of the section. Use it for element ids and per-copy CSS.
section.typeThe section's file name without .flys.
section.settings.<id>The value of a setting.
section.blocksThe list of blocks, in the order the merchant set.
section.blocks_sizeHow many blocks there are.

shop

PropertyMeaning
shop.nameThe store name.
shop.urlThe store's home address.
shop.emailThe contact email.
shop.phoneThe WhatsApp / phone number set in Settings.
shop.currencyThe currency symbol, for example Rs.
shop.currency_codeFor example PKR.
shop.products_countHow many live products.
shop.instagramThe Instagram handle.

collections, products

collections is a lookup by handle. collections.all always exists and holds every live product (first 100). Other collections hold up to 60 products, in the collection's own order. products (also all_products) looks up a live product by handle (first 300 products).

{% assign c = collections['summer-sale'] %}
{{ c.title }} ({{ c.products_count }})
{% for product in c.products limit: 4 %} ... {% endfor %}

{% assign p = products['linen-kurta'] %}
{{ p.title }} {{ p.price | money }}
Collection propertyMeaning
titleName
handleURL name
descriptionDescription (plain text)
imageCollection image address
urlLink to the collection page
productsThe products
products_countHow many

Product

PropertyMeaning
product.titleName
product.handleURL name
product.urlLink to the product page
product.categoryCategory (also product.type)
product.tagThe badge text, for example New
product.skuSKU
product.descriptionDescription (plain text)
product.pricePrice in cents. 4499 rupees is 449900. Print with | money.
product.compare_at_priceThe "was" price in cents, or empty
product.on_saletrue when it has a lower price than before
product.availabletrue when in stock
product.featured_imageThe first image address
product.imagesAll image addresses
product.sizesList of sizes
product.colorsList of colours
Prices are in cents, like Shopify, so code written for Shopify works unchanged. The money filter divides by 100 and adds your currency symbol and thousands separators: {{ 449900 | money }} prints Rs 4,499.

linklists (also menus) and pages

{% assign menu = linklists['main-menu'] %}
<nav>
  {% for link in menu.links %}
    <a href="{{ link.url }}">{{ link.title }}</a>
    {% for child in link.links %}<a href="{{ child.url }}">{{ child.title }}</a>{% endfor %}
  {% endfor %}
</nav>

{{ pages['about-us'].title }}
{{ pages['about-us'].content }}   {% comment %} cleaned HTML, printed as is {% endcomment %}

settings and routes

settings holds the theme's global settings: settings.bg, text, accent, onAccent, surface, inverseBg, inverseText, headingFont, bodyFont and more (see theme.json). For colours in CSS, prefer the CSS variables below. routes gives you root_url, collections_url, all_products_collection_url, cart_url and track_url.

Filters reference

Filters change a value: {{ value | filter: argument }}. You can chain them. All standard Liquid filters are available (upcase, truncate, split, join, size, default, date, plus, times, divided_by, newline_to_br, strip_html, json, url_encode and so on; see the LiquidJS filter list). These are added for stores:

FilterExampleResult
money{{ 449900 | money }}Rs 4,499
money_without_currency{{ 449900 | money_without_currency }}4,499
money_with_currency{{ 449900 | money_with_currency }}Rs 4,499 PKR
img_url{{ product.featured_image | img_url }}The image address
image_urlSame as img_url
img_tag{{ image | img_tag: "A photo", "rounded" }}A complete lazy-loading <img> with alt text and class
handleize{{ "Summer Sale!" | handleize }}summer-sale
pluralize{{ count | pluralize: "item", "items" }}item or items
escape{{ text | escape }}Safe text. Never escapes twice.

Snippets

A snippet is a piece of Liquid you reuse. Create one with + next to Snippets, then include it from any section:

{% render 'product-card', product: product, show_price: true %}

Inside snippets/product-card.flys, the values you pass in are plain variables:

<a class="card" href="{{ product.url }}">
  <div class="card-name">{{ product.title }}</div>
  {% if show_price %}<div class="price">{{ product.price | money }}</div>{% endif %}
</a>
  • A snippet sees what you pass in, plus the shared objects (shop, collections, products, linklists, pages, routes, settings). It does not see the section's own variables unless you pass them.
  • Snippets cannot have a schema, stylesheet or javascript block. Put those in the section that uses them.
  • If you delete a snippet that a section renders, that part of the section shows nothing.

Styling with CSS

There are two places for CSS: the {% stylesheet %} block of a section (loaded once per page, only when the section is used) and assets/custom.css (every page, loaded last, so it wins).

Use the theme's variables

Use the theme's CSS variables so your section follows the merchant's colours and fonts, including when they change theme.

VariableMeaning
--c-bgPage background
--c-textText colour
--c-accentAccent colour
--c-on-accentText on the accent colour
--c-surfaceCards and panels
--c-inv-bg / --c-inv-textDark (inverse) background and its text
--font-h / --font-bHeading and body fonts
--rCorner radius
--btn-rButton corner radius
--containerPage width

Colour schemes

Add one of sc-default, sc-surface, sc-inverse or sc-accent to a section element and it gets that scheme's background and text colour. Inside it, var(--bg), var(--text), var(--accent), var(--on-accent) and var(--surface) follow the scheme. Make it a setting to let merchants choose:

<section class="sec pad sc-{{ section.settings.scheme }}"> ... </section>

{% schema %}
{ "name": "Banner",
  "settings": [ { "type": "select", "id": "scheme", "label": "Colour scheme", "default": "default",
    "options": [ { "value": "default", "label": "Default" }, { "value": "surface", "label": "Surface" },
                 { "value": "inverse", "label": "Inverse" }, { "value": "accent", "label": "Accent" } ] } ] }
{% endschema %}

Ready-made classes

ClassUse
.wrapCentres content at the theme's page width
.sec .padA section with the theme's vertical spacing
.btn .btn-darkButtons. Also .btn-accent, .btn-light, .btn-ghost
.eyebrowThe small label above a heading
.mutedSofter text
.gridA product grid. Set the columns with style="--cols: 4"
.cardA product card with .card-img, .card-info, .card-cat, .card-name, .price inside
.tag.saleA "Sale" label (also .tag.out for sold out)

Good habits

  • Start every class in a section with the section's name (.hero-banner__title) so it cannot clash with other sections.
  • Make it work on phones: use clamp(), grid with auto-fit, and a @media (max-width: 760px) block.
  • Style per copy by putting section.id on an element: <div id="{{ section.id }}">.

JavaScript

Your store is a single-page app: when a shopper moves between pages, sections are drawn again without a full reload. So a script that looks for your section once, when the page first loads, can miss it. Use the section load event instead.

The fw:section:load event

It fires on the section's wrapper element, and bubbles up to document, every time a custom section appears on the page or is drawn again (including in the customizer preview when a setting changes).

event.detailMeaning
elThe section's wrapper element
idThe section's id (section.id)
typeThe section's file name, without .flys
{% javascript %}
  document.addEventListener('fw:section:load', function (e) {
    if (e.detail.type !== 'slider') return;          // only our section
    var root = e.detail.el;                         // the section's wrapper element
    var slides = root.querySelectorAll('.slider__slide');
    var i = 0;
    function show(n) {
      slides.forEach(function (s, k) { s.hidden = k !== n; });
    }
    show(0);
    root.querySelector('.slider__next').addEventListener('click', function () {
      i = (i + 1) % slides.length; show(i);
    });
  });
{% endjavascript %}

Where to put scripts

WhereRuns
{% javascript %} in a sectionOnce per page load, only when the section is used on the theme. Wrapped in a function and try/catch.
assets/custom.jsOn every page, once per page load.
layout/head.html, layout/body-end.htmlPlain tags: analytics, widgets.
  • Scripts run on your live storefront, not in the customizer preview (the preview only loads styles, so a script mistake can never break the editor).
  • Use event delegation (document.addEventListener('click', ...)) for behaviour that should survive the section being drawn again.
  • An error in a section script is logged to the browser console as Section <name>: ....

Using custom sections in the customizer

Once a section file has a valid schema it behaves like any other section.

  • Add it: Customize → Add section. Custom sections have a Custom tag and come after the built-in ones. You can add one to the home page or to a page template (product, collection, page, blog) in the template editor.
  • Edit it: select it in the list. Your settings become fields in the side panel, in the order and with the labels you wrote. Blocks appear as an Add block list the merchant can reorder.
  • Preview: the preview on the right re-renders the section on the server as you type, so it always matches what visitors will see.
  • Show or hide, duplicate, reorder, delete: the same controls as built-in sections.
  • Save and publish: like any theme change.

What happens when you change the code

  • Change the markup, CSS or script: every copy of the section updates as soon as you save the file.
  • Add or rename a setting: merchants see the new field. Existing copies get its default; values saved under an old id are dropped. Keep ids stable once a section is in use.
  • Delete the file: every copy of the section is removed from your theme. The editor asks you to confirm and tells you how many places lost it.

Building a whole theme

Pick any theme as a base, then use sections to build what you need: write your own hero, grids, banners and story blocks, hide the built-in sections you do not want, and restyle everything else with custom.css. The header, footer, product page, cart and checkout stay platform components (they handle prices, stock, the cart and payments), but you can change how they look with CSS and add your own sections above and below them in each page template.

Examples

A product row from any collection

Uses a collection setting, a loop, a snippet and the product grid classes. (Create the product-card snippet from the snippet starters.)

{% assign c = collections[section.settings.collection | default: 'all'] %}
<section class="sec pad">
  <div class="wrap">
    <h2>{{ section.settings.heading | default: c.title }}</h2>
    <div class="grid" style="--cols: {{ section.settings.columns }}">
      {% for product in c.products limit: section.settings.limit %}
        {% render 'product-card', product: product, show_price: true %}
      {% endfor %}
    </div>
  </div>
</section>

{% schema %}
{
  "name": "Product row",
  "settings": [
    { "type": "text", "id": "heading", "label": "Heading" },
    { "type": "collection", "id": "collection", "label": "Collection" },
    { "type": "range", "id": "limit", "label": "Products", "min": 2, "max": 12, "step": 1, "default": 4 },
    { "type": "range", "id": "columns", "label": "Columns", "min": 2, "max": 5, "step": 1, "default": 4 }
  ],
  "presets": [{ "name": "Product row" }]
}
{% endschema %}

A call-to-action strip with a colour scheme

<section class="sec pad sc-{{ section.settings.scheme }} cta">
  <div class="wrap cta__in">
    <div>
      <h2>{{ section.settings.heading }}</h2>
      <p>{{ section.settings.text }}</p>
    </div>
    <a class="btn btn-accent" href="{{ section.settings.link | default: routes.collections_url }}">{{ section.settings.button }}</a>
  </div>
</section>

{% stylesheet %}
  .cta__in { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
  .cta h2 { font-family: var(--font-h); margin: 0 0 6px; }
{% endstylesheet %}

{% schema %}
{
  "name": "Call to action",
  "settings": [
    { "type": "text", "id": "heading", "label": "Heading", "default": "Free delivery over Rs 5,000" },
    { "type": "text", "id": "text", "label": "Text", "default": "Cash on delivery available everywhere." },
    { "type": "text", "id": "button", "label": "Button", "default": "Shop now" },
    { "type": "url", "id": "link", "label": "Button link" },
    { "type": "select", "id": "scheme", "label": "Colour scheme", "default": "inverse",
      "options": [ { "value": "default", "label": "Default" }, { "value": "surface", "label": "Surface" }, { "value": "inverse", "label": "Inverse" }, { "value": "accent", "label": "Accent" } ] }
  ],
  "presets": [{ "name": "Call to action" }]
}
{% endschema %}

Troubleshooting

You seeWhyFix
Add a {% schema %} block...A section file needs a schema with a name.Add a {% schema %}{ "name": "My section" }{% endschema %} block.
The {% schema %} is not valid JSONA comma, quote or bracket is wrong.Check the line it points to. Trailing commas are not allowed in JSON.
Liquid error: illegal tag / unexpected tokenA tag is misspelled or not closed (endif, endfor).Match every if/for with its end tag.
a select needs "options"A select or radio has no options list.Add "options": [ {{ "value": "a", "label": "A" }} ].
the setting type "x" is not supportedThat Shopify type is not available here.Use a supported type, or a text setting.
My section is missing from Add sectionThe file has no valid schema, or a name that is empty.Open the file, fix the message shown when you save.
A red box in the previewA runtime error: a filter was used on the wrong kind of value, or a very slow loop.Read the message in the box. Sections that take longer than about 1.5 seconds or use too much memory are stopped.
My script does nothingIt looked for the section before it existed.Wait for fw:section:load (see JavaScript).
My script works on the store but not in the customizerThe customizer preview does not run scripts, on purpose.Check it on your live store.
Prices look 100× too largePrices are in cents.Print them with | money.
A setting I removed is still in the panelThe old copy of the page is open.Reload the customizer.

Safety limits

  • Templates run in a sandbox: they cannot read files, call the network or see another store's data.
  • Each render has a time limit (about 1.5 seconds) and a memory limit. A section that goes over is skipped and the page loads without it.
  • Setting values, product names and other store text are escaped before they reach your template.
Need a hand? Send us the file name and the message you see on Contact us, and we will help.