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.
Markup, styles, script and settings in one .flys file.
Override any rule of the theme in custom.css.
Run JavaScript when a section appears.
JavaScript →Every object, filter and setting type.
Reference →Quick start: your first section
This takes about five minutes and shows the whole loop: write, preview, save, place, edit.
- Open the editor. Online store → Themes → the live theme's ⋯ menu → Edit code.
- 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.flysopens. - 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.
- 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. - 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.
- Publish. Press Save in the customizer. Your section is live.
Files in the editor
The file list on the left shows everything that makes up your live theme.
| File | What it is | You can |
|---|---|---|
config/theme.json | All 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>.flys | A custom section: markup, styles, script and settings schema. | Create, edit, delete |
snippets/<name>.flys | A reusable piece of Liquid you include from sections with render. | Create, edit, delete |
assets/custom.css | CSS added to every storefront page, after the theme styles. | Edit |
assets/custom.js | JavaScript that runs on every storefront page. | Edit |
layout/head.html | Extra tags inside <head>: fonts, meta tags, verification tags. | Edit |
layout/body-end.html | Extra markup just before </body>: widgets, pixels. | Edit |
layout/theme.html | assets/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
| Shortcut | Action |
|---|---|
| Ctrl/⌘ + S | Save all changed files |
| Ctrl/⌘ + F | Search in the file |
| Ctrl/⌘ + G | Go to line |
| Ctrl/⌘ + / | Comment or uncomment the selection |
| Tab / Shift + Tab | Indent 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.
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 %}
| Part | What it does |
|---|---|
| Markup | Everything 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
| Key | Required | Meaning |
|---|---|---|
name | Yes | The title merchants see in Add section and in the section list. Up to 40 characters. |
settings | No | The list of settings merchants can change (up to 40). See the types below. |
blocks | No | Repeatable items inside the section, such as slides, questions or features (up to 12 block types). |
max_blocks | No | How many blocks one section may hold. Default 16, maximum 30. |
presets | No | The first preset gives the default values and the starting blocks a new copy of the section gets. |
class | No | An extra class added to the section wrapper. |
Setting attributes
| Attribute | Meaning |
|---|---|
type | One of the types below. |
id | The name you use in Liquid: section.settings.<id>. Letters, numbers and underscores, starting with a letter. Must be unique in its section. |
label | The field label merchants see. |
default | The starting value. |
info | A short help text under the field. |
The ids blocks (in a section) and type (in a block) are reserved.
Setting types
| Type | Merchant sees | In Liquid you get | Notes |
|---|---|---|---|
text | A one-line field | A string | maxlength up to 500 (default 200). |
textarea | A multi-line field | A string | Use | newline_to_br to keep line breaks. maxlength up to 4000. |
richtext | A multi-line field | A string | Plain text. HTML is shown as text for safety. |
number | A one-line field | A string of digits | Do maths with | plus: 0 to turn it into a number. |
checkbox | A switch | true or false | |
select | A drop-down (or buttons) | The chosen option's value | Needs options: a list of {{ "value", "label" }}. The default must be one of them, otherwise the first is used. |
radio | Same as select | Same as select | |
range | A slider | A number | Needs min, max (larger than min) and optional step and unit. |
color | A colour picker | A hex string like #1a1a1a | The default must be a 6-digit hex colour. |
image_picker | Select image (from the Files library) | An image address, or empty | Print it with | img_url. Check != blank first. |
url | A one-line field | A string | Addresses starting with javascript: are removed. |
collection | A collection drop-down | A collection handle, or empty | Use it as collections[section.settings.collection]. Empty means all products. |
link_list | A menu drop-down | A menu handle, or empty | Use it as linklists[section.settings.menu]. |
header | A bold heading in the panel | Nothing | Groups settings. Use "content" for the text. |
paragraph | A line of help text in the panel | Nothing | Use "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
| Property | Meaning |
|---|---|
section.id | A unique id for this copy of the section. Use it for element ids and per-copy CSS. |
section.type | The section's file name without .flys. |
section.settings.<id> | The value of a setting. |
section.blocks | The list of blocks, in the order the merchant set. |
section.blocks_size | How many blocks there are. |
shop
| Property | Meaning |
|---|---|
shop.name | The store name. |
shop.url | The store's home address. |
shop.email | The contact email. |
shop.phone | The WhatsApp / phone number set in Settings. |
shop.currency | The currency symbol, for example Rs. |
shop.currency_code | For example PKR. |
shop.products_count | How many live products. |
shop.instagram | The 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 property | Meaning |
|---|---|
title | Name |
handle | URL name |
description | Description (plain text) |
image | Collection image address |
url | Link to the collection page |
products | The products |
products_count | How many |
Product
| Property | Meaning |
|---|---|
product.title | Name |
product.handle | URL name |
product.url | Link to the product page |
product.category | Category (also product.type) |
product.tag | The badge text, for example New |
product.sku | SKU |
product.description | Description (plain text) |
product.price | Price in cents. 4499 rupees is 449900. Print with | money. |
product.compare_at_price | The "was" price in cents, or empty |
product.on_sale | true when it has a lower price than before |
product.available | true when in stock |
product.featured_image | The first image address |
product.images | All image addresses |
product.sizes | List of sizes |
product.colors | List of colours |
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:
| Filter | Example | Result |
|---|---|---|
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_url | Same 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.
| Variable | Meaning |
|---|---|
--c-bg | Page background |
--c-text | Text colour |
--c-accent | Accent colour |
--c-on-accent | Text on the accent colour |
--c-surface | Cards and panels |
--c-inv-bg / --c-inv-text | Dark (inverse) background and its text |
--font-h / --font-b | Heading and body fonts |
--r | Corner radius |
--btn-r | Button corner radius |
--container | Page 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
| Class | Use |
|---|---|
.wrap | Centres content at the theme's page width |
.sec .pad | A section with the theme's vertical spacing |
.btn .btn-dark | Buttons. Also .btn-accent, .btn-light, .btn-ghost |
.eyebrow | The small label above a heading |
.muted | Softer text |
.grid | A product grid. Set the columns with style="--cols: 4" |
.card | A product card with .card-img, .card-info, .card-cat, .card-name, .price inside |
.tag.sale | A "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(),gridwithauto-fit, and a@media (max-width: 760px)block. - Style per copy by putting
section.idon 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.detail | Meaning |
|---|---|
el | The section's wrapper element |
id | The section's id (section.id) |
type | The 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
| Where | Runs |
|---|---|
{% javascript %} in a section | Once per page load, only when the section is used on the theme. Wrapped in a function and try/catch. |
assets/custom.js | On every page, once per page load. |
layout/head.html, layout/body-end.html | Plain 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 see | Why | Fix |
|---|---|---|
| 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 JSON | A comma, quote or bracket is wrong. | Check the line it points to. Trailing commas are not allowed in JSON. |
| Liquid error: illegal tag / unexpected token | A 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 supported | That Shopify type is not available here. | Use a supported type, or a text setting. |
| My section is missing from Add section | The 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 preview | A 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 nothing | It looked for the section before it existed. | Wait for fw:section:load (see JavaScript). |
| My script works on the store but not in the customizer | The customizer preview does not run scripts, on purpose. | Check it on your live store. |
| Prices look 100× too large | Prices are in cents. | Print them with | money. |
| A setting I removed is still in the panel | The 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.