Theme architecture
How layouts, JSON templates, sections, blocks and snippets fit together into a page.
A storefront page is built in layers. Each layer has one job, and the merchant controls the parts in the middle.
layout/theme.twig the HTML shell: <head>, header group, footer group
└─ templates/product.json which sections the offer page shows, in what order
└─ sections/…/main-product a band of the page, with settings
└─ blocks/…/price a piece inside a section, can nest other blocks
└─ snippets/… a partial the developer calls with render()
Layout
layout/theme.twig is the document around every page. It prints two things the platform prepares:
{{ content_for_header }}inside<head>- meta tags, canonical, Open Graph, the theme's section stylesheet, preconnects and the scripts the merchant added. Always print it.{{ content_for_layout }}where the page content goes - the rendered sections of the template.
Around them the layout renders section groups - {{ sections('header-group') }} and {{ sections('footer-group') }} - so the merchant edits the header and footer in the editor like any other section.
<!doctype html>
<html lang="{{ shop.locale }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ page_title ? page_title ~ ' - ' ~ shop.name : shop.name }}</title>
{{ 'css/theme.css'|asset_url|stylesheet_tag }}
{{ render('brand-tokens') }}
{{ content_for_header }}
</head>
<body class="tpl-{{ template }}">
{{ sections('header-group') }}
<main id="main">{{ content_for_layout }}</main>
{{ sections('footer-group') }}
{{ 'js/theme.js'|asset_url|script_tag }}
</body>
</html>
The platform replaces your <title> with the title from the store's SEO settings, so write a sensible fallback and do not worry about it further. See SEO.
Templates
A template is JSON: a list of sections with their settings and blocks, and their order. There is no Twig in templates/.
{
"sections": {
"main": { "type": "main-product", "settings": { "sticky_info": true } },
"related": { "type": "featured-products", "settings": { "heading": "You may also like" } }
},
"order": ["main", "related"]
}
The file in your theme is the starting point. When a merchant rearranges sections in the editor, their version is stored with their store and wins over yours. See Templates.
Sections
A section is a horizontal band of a page - a hero, a product grid, the main product area. It is a Twig file with a {% schema %} that declares its name, settings and the blocks it accepts. The merchant adds sections to templates, reorders them and fills their settings.
Blocks
A block is a piece inside a section - a heading, a price, a button, a tile. Theme blocks live in blocks/, have their own schema and can contain other blocks, so a merchant can build Group → Columns → Text + Button without you writing that combination. A section renders its blocks with {{ content_for('blocks') }}.
Snippets
A snippet is a partial for you, not for the merchant - a product card, an icon, a price line. It has no schema and the merchant never sees it. Call it with {{ render('product-card', { product: item }) }}; it sees only what you pass plus shop, settings and cart.
Note
Block or snippet? If the merchant should add, remove or configure it, it is a block. If it is a building piece of your own markup, it is a snippet. The schema decides: a block must have one, a snippet must not - files that break this do not save.
The core library
The platform ships a library of sections and blocks to every theme - product-list, faq, newsletter, testimonials, heading, paragraph and more. They style themselves with your brand tokens, so they fit your theme out of the box, and you can replace any of them by shipping a file with the same name. See Core sections and blocks.
Data
Templates never see the database. The controller of each page hands over objects - product, category, cart - and the sandbox lets a template read their fields and call a few functions, nothing else. Each page type gets its own variables; see Page types.
Rendering and caching
Pages are rendered on the server and cached as finished HTML, shared by every visitor of the store, and each section is cached as a fragment. Your markup must therefore be the same for everyone: nothing about the visitor, their cart or their session. Anything personal is read in the browser from the JSON APIs. Performance and caching covers the rules.