# Themes
Source: https://shopdepot.dev/docs/themes/
A theme is the look of a ShopDepot store: the HTML, CSS and JavaScript of every storefront page. It is a folder of Twig templates, JSON and assets that the platform renders for each request, with the store's data passed in as read-only [objects](../reference/objects/index.md).
If you have built a Shopify Online Store 2.0 theme, most of this will feel familiar on purpose: layouts, JSON templates, sections, theme blocks, snippets, `{% schema %}`, `settings_schema.json` and locales work the same way. The templating language is **Twig** instead of Liquid, and it runs in a sandbox.
## What a theme controls
- **Page layouts** - the home page, offer pages, categories, content pages, the blog, search, the cart, feature pages (authors, brands) and the 404 page. See [Page types](../reference/page-types.md).
- **Sections and blocks** the merchant arranges in the theme editor, with the settings you declare.
- **Theme settings** - colours, fonts, logo, layout options - shared by every page.
- **Styles of platform components** - the contact form and the cart summary - through stable class names.
- **Brand tokens** the platform reuses on its own pages in the store.
## What the platform keeps
Some parts of a store are the same in every theme, because they have to work the same way everywhere and stay compliant:
| Area | Why the platform owns it |
| --- | --- |
| Checkout and the thank you page | Payments, consents and order rules. Merchants brand it in their settings. |
| Customer accounts, returns and complaints | Personal data and legal deadlines. |
| `
` metadata - description, canonical, Open Graph, robots | One SEO model per store, set by the merchant. |
| The contact form, newsletter sign-up and the cart summary | Consents, validation, rate limits and spam protection. |
| Scripts and tracking pixels | Added by the merchant, loaded only with consent. |
Your theme inherits all of this. It never has to implement a checkout or a login form, and it cannot break them. The pages the platform renders inside the store still look like your theme: they take colours, radius and fonts from your [brand tokens](platform-pages.md#brand-tokens).
## How a theme gets to a store
1. You build the theme locally, starting from the reference theme `base`.
2. You push it to a development store with the [CLI](cli.md) (or upload a ZIP), and the ShopDepot team publishes it to the theme registry.
3. The merchant installs it from the [theme store](publishing.md) or their library, customizes it in the theme editor and publishes it.
Every installation is a copy: the merchant's settings and edits live with their store, and a new version of your theme arrives as an update they accept.
## Where to go next
- [Create your first theme](getting-started.md)
- [Learn the architecture](architecture.md)
- [Browse the reference](../reference/index.md)
---
# Create a theme
Source: https://shopdepot.dev/docs/themes/getting-started/
This guide takes you from nothing to your own theme running on real store data. You need a code editor, a terminal and a ShopDepot development store.
## 1. Get a development store
A development store is a separate ShopDepot account made for building: it has no plan limits, no billing clock, and paid themes are fully editable and publishable there. Development stores are created by the ShopDepot team today - write to us from [shopdepot.pl](https://shopdepot.pl/) and we set one up with sample categories and offers. Self-service partner accounts are on the roadmap.
> [!TIP]
> Build against data that looks like your target merchants'. A theme tested on three products with one photo each will break on a catalogue with long titles, many variants and no images.
## 2. Install the CLI
```bash
curl -fsSL https://shopdepot.dev/install.sh | sh
```
On Windows, download the `.exe` from the [CLI page](cli.md#install). Then create a developer token in the development store (**Sales channels → Stores → your store → Appearance → Themes → Developer access**) and connect:
```bash
shopdepot login
```
## 3. Start from `base`
Every ShopDepot theme starts as a copy of **base**, the free reference theme. It covers every page type, uses the conventions the theme store checks for, and is small enough to read in an afternoon.
```bash
shopdepot theme init example
cd example
```
`init` downloads base into a new folder and gives the copy its own identity: the `handle` becomes `example` and the version `0.1.0`. Fill in the rest of `theme.json` - the `handle` identifies your theme in the registry and cannot be changed later:
```json
{
"name": "Example",
"handle": "example",
"version": "0.1.0",
"author": "Example Studio",
"description": "A calm theme for small catalogues."
}
```
See [theme.json](theme-json.md) for every key.
## 4. Look around
```text
example/
├── theme.json the manifest
├── layout/theme.twig the HTML shell of every page
├── templates/*.json which sections each page type shows
├── sections/ sections, in folders if you like
├── blocks/ theme blocks the merchant can nest
├── snippets/ partials for developers
├── assets/ CSS, JavaScript, fonts, images
├── config/ the theme settings schema and starting values
└── locales/ storefront texts in each language
```
Open `templates/product.json` and follow it: it names the `main-product` section, which renders blocks like `price` and `buy-buttons`, which call snippets like `product-card`. That path - **template → section → block → snippet** - is the whole architecture. [Architecture](architecture.md) explains it properly.
## 5. Push and preview
Upload the folder as a new draft theme, then start the development loop:
```bash
shopdepot theme push --new
shopdepot theme dev
```
`dev` prints a preview link and uploads every file as you save it. Open the link: it shows your theme on the store's real data without publishing it. Change a colour in `assets/css/base.css` or a line in `sections/content/hero.twig`, save, refresh.
A file the platform refuses - a Twig syntax error, a filter the [sandbox](twig-sandbox.md) does not allow, a path outside the [file contract](file-structure.md) - is reported in the terminal with the reason and is not saved, so the preview keeps working on the previous version.
In the admin, under **Appearance → Themes**, the theme is in the library as a draft. From there you can also **Customize** it in the theme editor, exactly as a merchant would, and **Publish** it to make it the live theme of the development store.
## 6. Check and package
Before you show the theme to anyone, run the checks and build the package:
```bash
shopdepot theme check
shopdepot theme package
```
`check` runs every file through the platform's rules and points out common mistakes. `package` writes `example-0.1.0.zip` with exactly the files the platform accepts. Bump `version` in `theme.json` before each package you hand over - versions are never overwritten.
> [!NOTE]
> You can still work without the CLI: zip the folder with `theme.json` at the top and use **Appearance → Themes → Upload your own theme** in the admin. The upload screen lists every file the contract left out - check it, because a missing font or image shows up later as a 404.
## 7. Keep going
- Read [Sections and blocks](sections-and-blocks.md) before you add your first section.
- Keep the [Twig sandbox rules](twig-sandbox.md) in mind - templates that break them do not save.
- Every command and option: [ShopDepot CLI](cli.md).
- Run through the [review checklist](checklist.md) before you submit the theme.
---
# Using AI assistants
Source: https://shopdepot.dev/docs/themes/ai-assistants/
AI assistants write good ShopDepot themes when they work from this documentation, and bad ones when they guess from Shopify or plain Twig. Give them the docs.
## Connect the MCP server
ShopDepot runs a [Model Context Protocol](https://modelcontextprotocol.io/) server for theme development at:
```text
https://shopdepot.dev/mcp
```
It is public: no account, no token, no installation. Once it is connected, your assistant can search and read these docs, look up the exact reference entry for an object, filter, function or tag, and check theme files against the same rules the platform applies when it saves a file. It does not read or change any store.
| Tool | What the assistant uses it for |
| --- | --- |
| `search_docs` | Find the guide or reference page for a task. |
| `get_doc` | Read a page as Markdown (`index` lists every page). |
| `lookup_reference` | The exact entry for `product`, `image_url`, `cart_summary`, `schema`... If it is not there, the sandbox refuses it. |
| `validate_theme_files` | Check changed files: the file contract, JSON and `{% schema %}`, Twig syntax and the sandbox, plus common mistakes. Nothing is saved. |
The server also gives the assistant a short set of rules when it connects, so it works from the docs instead of guessing from Shopify or plain Twig.
**Claude Code**
```bash
claude mcp add --transport http shopdepot https://shopdepot.dev/mcp
```
**Claude (desktop and web)** - open **Settings → Connectors → Add custom connector**, name it ShopDepot and paste the address.
**Cursor** - `.cursor/mcp.json` in the theme folder (or `~/.cursor/mcp.json` for every project):
```json
{
"mcpServers": {
"shopdepot": { "url": "https://shopdepot.dev/mcp" }
}
}
```
**VS Code** - `.vscode/mcp.json`:
```json
{
"servers": {
"shopdepot": { "type": "http", "url": "https://shopdepot.dev/mcp" }
}
}
```
**Other clients** - any client that supports the Streamable HTTP transport takes the address as it is. A client that only starts local servers can reach it through a bridge, for example `npx mcp-remote https://shopdepot.dev/mcp`.
> [!TIP]
> Ask the assistant to call `validate_theme_files` after every change and fix each error before it moves on. Pass `theme.json` along with the files to run the whole-theme checks as well.
## Plain Markdown for every page
- Add `.md` to any page address for its Markdown source - this page is [`/docs/themes/ai-assistants.md`](/docs/themes/ai-assistants.md).
- Every page has **Copy page as Markdown** at the top - paste it into a chat.
- [`/llms.txt`](/llms.txt) lists every page with a one-line description, in the [llms.txt](https://llmstxt.org/) format.
- [`/llms-full.txt`](/llms-full.txt) is the whole documentation in one file, for assistants with a large context.
The reference pages are generated from the platform code, so an assistant reading them sees exactly which objects, filters and functions exist.
## Tell your assistant the rules
Paste this at the start of a session, or put it in your project's instruction file (`CLAUDE.md`, `AGENTS.md`, `.cursorrules`):
```text
This is a ShopDepot storefront theme. Documentation: https://shopdepot.dev/llms.txt
Rules:
- Templates are Twig in a sandbox. Use only the tags, filters and functions listed at
https://shopdepot.dev/docs/reference/filters.md, /functions.md and /tags.md.
No extends, macro, import or block. Reuse markup with render('snippet-name', {...}).
- Read data only from objects (https://shopdepot.dev/docs/reference/objects.md).
Property names are camelCase: product.featuredMedia, not product.featured_media.
- Prices are integers in minor units. Always format with |money.
- Files: lowercase paths, at most 4 levels deep, sections/blocks/snippets referenced by
file name only. Blocks need {% schema %}, snippets must not have one.
- Pages are cached and shared by all visitors: never print customer or cart data in
sections. Read the cart with fetch('/cart.js').
- Store addresses end with a trailing slash: /cart/, /products/example/.
- The platform writes and meta tags in content_for_header - do not add your own
description, canonical or Open Graph tags.
- The first visible image needs loading: 'eager' or fetchpriority="high"; every other
image is lazy automatically.
```
## Let the assistant check its own work
An assistant that edits a theme in your folder can verify what it wrote with the [CLI](cli.md), using the same rules the platform applies on save:
```bash
shopdepot theme check
```
Ask it to run `check` after every change and fix each error before it moves on. With `shopdepot theme dev` running in another terminal, every file it saves goes to your development store, and a file the platform refuses is reported with the reason instead of being saved.
---
# ShopDepot CLI
Source: https://shopdepot.dev/docs/themes/cli/
`shopdepot` is the command line tool for theme developers. It starts a theme from the reference theme, keeps a folder on your computer in sync with a theme in a store, shows you a live preview while you edit and checks the theme against the same rules the platform applies when it saves a file.
It is a single file with no dependencies. It talks to the [theme API](theme-api.md) with a developer token, so it never needs your admin password.
## Install
On macOS and Linux:
```bash
curl -fsSL https://shopdepot.dev/install.sh | sh
```
The script picks the build for your system, checks it against the published SHA-256 checksum and installs it to `~/.local/bin/shopdepot`. Set `SHOPDEPOT_INSTALL_DIR` to install somewhere else. If `~/.local/bin` is not on your `PATH`, the script prints the line to add to your shell profile.
On Windows, download [shopdepot-windows-amd64.exe](/cli/shopdepot-windows-amd64.exe), rename it to `shopdepot.exe` and put it in a folder on your `PATH`.
All builds and their checksums:
| System | File |
| --- | --- |
| macOS, Apple silicon | [shopdepot-darwin-arm64](/cli/shopdepot-darwin-arm64) |
| macOS, Intel | [shopdepot-darwin-amd64](/cli/shopdepot-darwin-amd64) |
| Linux, x86-64 | [shopdepot-linux-amd64](/cli/shopdepot-linux-amd64) |
| Linux, ARM64 | [shopdepot-linux-arm64](/cli/shopdepot-linux-arm64) |
| Windows, x86-64 | [shopdepot-windows-amd64.exe](/cli/shopdepot-windows-amd64.exe) |
| Checksums | [SHA256SUMS](/cli/SHA256SUMS) |
Check the installation:
```bash
shopdepot version
```
To update, run the install command again.
## Connect a store
Each store you work on needs a **developer token**. In the store admin open **Sales channels → Stores → your store → Appearance → Themes → Developer access**, give the token a name (your name, or the laptop it lives on) and create it. The token starts with `sdt_` and is shown **once** - copy it straight away.
```bash
shopdepot login
```
Paste the token when asked. The CLI checks it with the store, saves it under the store's handle and makes it the default store if it is your first one. You can pass everything at once:
```bash
shopdepot login --token sdt_... --store example
```
A token gives access to the themes of **one store** and nothing else: no orders, customers or settings. Revoke it on the same screen at any time - tools using it lose access at once. A store can have up to 20 tokens; create one per person and per machine, so that revoking one does not lock everybody out.
> [!TIP]
> Work in a **development store**. There, paid themes are editable and publishable, and nothing you push reaches real customers. In a live store, a paid theme on trial is read-only and `push` refuses it.
| Command | What it does |
| --- | --- |
| `shopdepot login [--store NAME] [--token sdt_...]` | Save a token. `NAME` defaults to the store handle. |
| `shopdepot stores` | List saved stores; the default is marked. |
| `shopdepot logout [--store NAME]` | Forget a saved token (revoke it in the admin too). |
Tokens are saved in your user configuration folder (`~/.config/shopdepot/config.json` on Linux, `~/Library/Application Support/shopdepot/config.json` on macOS, `%AppData%\shopdepot\config.json` on Windows), readable only by you. `SHOPDEPOT_CONFIG` points the CLI at another file.
## Start a theme
```bash
shopdepot theme init example
cd example
```
`init` downloads the current version of **base**, the free reference theme, into a new folder and renames it after the folder: `handle` becomes `example`, the version resets to `0.1.0` and the author is cleared. Fill in `name`, `author` and `description` in [theme.json](theme-json.md) - the `handle` identifies the theme in the registry and cannot change later.
`init` also writes:
- `.shopdepot.json` - which store and theme this folder belongs to (keep it out of git; `init` adds it to `.gitignore`),
- `.shopdepotignore` - patterns of files that never go to the store.
Upload the folder as a new theme:
```bash
shopdepot theme push --new
```
The theme is added to the store's library as a **draft** and the folder remembers it, so later commands need no `--theme`. The command prints a preview link.
## The development loop
```bash
shopdepot theme dev
```
`dev` first uploads anything that differs from the store, then watches the folder. Every file you save goes up within about a second, every file you delete is removed from the theme, and each change is printed with a mark:
```text
Watching /home/you/example → "Example"
Preview: https://example.myshopdepot.pl/?preview_theme=...
Press Ctrl+C to stop.
14:02:11 ✓ sections/content/hero.twig
14:02:19 ! sections/content/hero.twig: Unexpected "}" (line 12)
14:02:25 ✓ sections/content/hero.twig
14:03:40 ✗ snippets/old-card.twig
```
A file the platform refuses (a Twig syntax error, a filter the [sandbox](twig-sandbox.md) does not allow, a path outside the [file contract](file-structure.md)) is marked `!` with the reason and **not saved** - the theme keeps the previous version, so the preview never shows a broken page. Fix the file and save again.
Open the preview link and refresh after a change. The link shows your theme on the store's real data without publishing it, for you and anyone you send it to, and stays active in that browser for a day. Add `?preview_theme=off` to any store address to leave the preview.
`--interval 1s` changes how often the folder is checked (the default is 500 ms).
## Commands
Every theme command accepts `--store NAME` (default: the store the folder belongs to, then the default store) and `--path DIR` (default: the current folder). `--theme ID` selects a theme by the id `theme list` prints; without it, the folder's theme is used.
| Command | What it does |
| --- | --- |
| `shopdepot theme init [DIR]` | Start a theme from `base` in a new folder (default `example-theme`). |
| `shopdepot theme list` | Themes installed in the store: id, name, role (live or draft), licence and whether you can edit them. |
| `shopdepot theme pull [--theme ID] [--only GLOB]` | Download a theme into the folder. Only changed files are written. |
| `shopdepot theme push [--theme ID] [--only GLOB] [--nodelete] [--dry-run] [--publish]` | Upload local changes. |
| `shopdepot theme push --new [--publish]` | Upload the folder as a new draft theme and link the folder to it. |
| `shopdepot theme dev [--theme ID] [--interval 500ms]` | Push every change as you save and print the preview link. |
| `shopdepot theme check [--strict]` | Check the theme against the platform rules without changing the store. |
| `shopdepot theme open [--theme ID] [--page /products/example/]` | Open the preview in your browser. |
| `shopdepot theme package [--out FILE]` | Build the ZIP you upload in the admin or submit to the theme store. |
### push
`push` compares checksums and uploads only what changed. Files that are in the theme but not in your folder are **deleted** from the theme, so the store ends up exactly like the folder; `--nodelete` keeps them. Use `--dry-run` to see the plan first:
```bash
shopdepot theme push --dry-run
```
`--only` limits a push or pull to matching paths and can be repeated:
```bash
shopdepot theme push --only 'sections/*' --only 'assets/css/base.css'
```
`--publish` makes the theme live after the push. In a store with customers, prefer publishing from the admin, where you see the theme next to the live one.
`push` never overwrites `config/settings_data.json` in the store, because it holds the values set in the theme editor. To replace them with your file on purpose, name it:
```bash
shopdepot theme push --only config/settings_data.json
```
(`dev` does upload it when you edit and save it, since that is a deliberate change.) Pull before you push when someone else, or the merchant in the theme editor, may have changed the theme: `templates/*.json` change too every time the theme is customized in the editor.
### check
```bash
shopdepot theme check
```
`check` sends the folder to the platform and runs every file through the same rules as a save: the [file contract](file-structure.md), JSON and `{% schema %}` syntax, Twig syntax and the [sandbox](twig-sandbox.md). It also reports problems that are allowed but usually a mistake:
- `layout/theme.twig` missing `{{ content_for_header }}` or `{{ content_for_layout }}`, or writing its own description, canonical or Open Graph tags,
- a missing `snippets/brand-tokens.twig` or a missing template for a page type,
- a section or block whose root element does not print `section.attributes` / `block.attributes`,
- files outside the contract, which would be skipped silently on upload.
Errors make the command exit with status 1; `--strict` does the same for warnings, which is what you want in continuous integration:
```yaml
# .gitlab-ci.yml or any CI
theme-check:
script:
- curl -fsSL https://shopdepot.dev/install.sh | sh
- ~/.local/bin/shopdepot theme check --strict
variables:
SHOPDEPOT_TOKEN: $SHOPDEPOT_TOKEN
```
`check` reads the store only to run the rules - it never changes a theme.
### package
```bash
shopdepot theme package
```
Writes `-.zip` with exactly the files the platform accepts, `theme.json` at the top of the archive. Bump `version` in `theme.json` before every package you hand over: versions in the registry are never overwritten. See [Publishing](publishing.md).
## Ignored files
These never go to the store and are never deleted from it by `push`: `.git`, `node_modules`, `.DS_Store`, `.shopdepot.json`, and the `demo/` folder (demo store data ships in the package, not in a store's theme). Add your own patterns to `.shopdepotignore`, one per line:
```text
# source files compiled into assets/
src/
*.map
assets/*.scss
```
A pattern without `/` matches a name at any depth; a pattern with `/` matches from the theme root; a trailing `/` matches a folder.
## Automation and CI
`SHOPDEPOT_TOKEN` (and optionally `SHOPDEPOT_API`) override the saved stores, so a pipeline needs no `login`:
```bash
SHOPDEPOT_TOKEN=sdt_... shopdepot theme push --theme 0193d7a2-... --nodelete
```
Keep the token in your CI's secret variables, never in the repository. Create a separate token for CI so you can revoke it without touching your own.
## Troubleshooting
| Message | What to do |
| --- | --- |
| `Missing or invalid token` | The token was revoked or mistyped. Create a new one and run `shopdepot login` again. |
| `"Example" is read-only in this store (licence: trial)` | A paid theme on trial cannot be changed. Buy it in the store, or work in a development store. |
| `outside the theme file contract` | Rename the file: lowercase letters, at most four folders deep, inside one of the theme folders. See [File structure](file-structure.md). |
| `Unexpected ... (line 12)` | A Twig syntax error. The file was not saved; the store still has the previous version. |
| `Filter "..." is not allowed` (or tag, function, method) | The template uses a tag, filter, function or method themes cannot call. See [The Twig sandbox](twig-sandbox.md). |
| `no theme.json in this folder` | Run the command inside the theme folder, or pass `--path`. |
---
# Theme API
Source: https://shopdepot.dev/docs/themes/theme-api/
The theme API is what the [ShopDepot CLI](cli.md) uses. Use it directly when you build your own tooling: an editor plugin, a deploy script, a build step that uploads compiled assets.
```text
https://hooks.shopdepot.pl/theme-api/v1
```
Every request and every response is JSON unless noted otherwise. The API works on the themes of **one store** - the store the token belongs to.
## Authentication
Create a developer token in the store admin: **Sales channels → Stores → your store → Appearance → Themes → Developer access**. Send it in the `Authorization` header:
```bash
curl https://hooks.shopdepot.pl/theme-api/v1/store \
-H "Authorization: Bearer sdt_..."
```
The token is shown once and stored only as a hash. It reads and writes themes of its store and nothing else. Revoking it in the admin takes effect on the next request. A missing, mistyped or revoked token answers `401`.
## Errors
Errors are JSON with a message for a human and, for file operations, the path:
```json
{ "error": "Unexpected \"}\" (line 12)", "path": "sections/content/hero.twig" }
```
| Status | Meaning |
| --- | --- |
| `401` | No token, or the token is invalid or revoked. |
| `403` | The theme cannot be changed or published: a paid theme on trial, or a licence that does not allow it. |
| `404` | No such theme in this store, or no such file. |
| `422` | The request was refused by a platform rule. The file or theme did not change. |
## Store
### `GET /store`
The store of the token and its themes. Use it to check a token.
```json
{
"store": { "name": "Example", "handle": "example", "url": "https://example.myshopdepot.pl/", "locale": "pl", "currency": "PLN" },
"token": { "name": "Laptop" },
"themes": [ { "id": "0193d7a2-...", "name": "Example", "role": "unpublished" } ]
}
```
## Themes
### `GET /themes`
```json
{ "themes": [ THEME, ... ] }
```
A theme object:
| Key | Description |
| --- | --- |
| `id` | Theme id - use it in every theme address. |
| `name` | Name in the library. |
| `role` | `published` for the live theme, `unpublished` or `development` for the others. |
| `package` | `{ "handle", "version" }` of the registry package it was installed from, or `null`. |
| `license` | Licence state of a paid theme in this store: `not_required` (free theme), `trial`, `active` (bought), `expired` (live, no more updates) or `development` (development store). |
| `editable` | Whether files can be written. `false` for a paid theme on trial. |
| `publishable` | Whether the theme can be published. |
| `managed_by` | The tool that keeps the theme's code outside the store (for example `studio`), or `null`. See [`PATCH /themes/{id}`](#patch-themesid). |
| `available_update` | A newer published version of `package`, or `null`. For a theme with `managed_by` it is only information: the store never applies it. |
| `updated_at` | Last change, ISO 8601. |
| `preview_url` | A link that shows this theme on the store's data without publishing it. |
### `GET /themes/{id}`
The theme and its files, sorted by path:
```json
{
"theme": THEME,
"files": [
{ "path": "assets/css/base.css", "checksum": "9f2c...", "size": 18213, "binary": false, "updated_at": "2026-11-15T14:02:11+01:00" }
]
}
```
`checksum` is the SHA-256 of the file's bytes. Compare it with the SHA-256 of your local file to know what changed - that is how `shopdepot theme push` uploads only differences.
### `POST /themes`
Creates a theme in the store's library, always as a draft. Two forms:
Upload a ZIP (`multipart/form-data`, field `archive`, at most 50 MB):
```bash
curl https://hooks.shopdepot.pl/theme-api/v1/themes \
-H "Authorization: Bearer sdt_..." \
-F archive=@example-0.1.0.zip
```
The archive becomes a private package of the store's account (only this account can install it) and is installed. `theme.json` must be at the top of the archive or inside one top-level folder, and its `version` must be new - versions are never overwritten. The response lists files the platform left out because they break the [file contract](file-structure.md):
```json
{ "theme": THEME, "skipped": ["assets/Fonts/Mono.woff2"] }
```
Copy a theme of this store:
```json
{ "duplicate": "0193d7a2-...", "name": "Example - experiment" }
```
Both answer `201`. Add `managed_by` (a JSON key, or a form field next to `archive`) to create the theme as managed outside the store from the start.
### `PATCH /themes/{id}`
Says who keeps the theme's code:
```json
{ "managed_by": "studio" }
```
Use it when the theme's code lives in a repository and is sent with this API. Package files then never land on the theme by themselves: the nightly update skips it, the library shows no **Update** button and the theme cannot be reset to the package version. A newer package version still shows in `available_update`, so your tool can propose the update as a change in the repository. `managed_by` is lowercase letters, digits and `-`, at most 40 characters. `{ "managed_by": null }` hands the theme back to the store - the merchant can also do it with **Detach from Studio** in the library. Answers `200` with `{ "theme": THEME }`.
### `POST /themes/{id}/publish`
Makes the theme live. `403` when the licence does not allow it.
### `GET /themes/{id}/preview?path=/products/example/`
```json
{ "url": "https://example.myshopdepot.pl/products/example/?preview_theme=..." }
```
Opening the link shows the theme to that browser for a day. `?preview_theme=off` ends the preview.
## Files
Paths are theme paths as in the [file structure](file-structure.md), for example `sections/content/hero.twig`, without a leading slash.
### `GET /themes/{id}/files/{path}`
The file itself: text as `text/plain; charset=UTF-8`, images and fonts as bytes. The `X-Checksum` header carries the SHA-256.
### `PUT /themes/{id}/files/{path}`
The request body is the new content: UTF-8 text, or bytes for an image or font in `assets/`. Creates the file or replaces it.
```bash
curl -X PUT https://hooks.shopdepot.pl/theme-api/v1/themes/0193d7a2-.../files/sections/content/hero.twig \
-H "Authorization: Bearer sdt_..." \
--data-binary @sections/content/hero.twig
```
```json
{ "path": "sections/content/hero.twig", "checksum": "9f2c...", "size": 1264 }
```
A write goes through the same rules as the code editor in the admin, and a refused file is **not saved**:
- the [file contract](file-structure.md) - path, kind, size,
- JSON syntax, and the `{% schema %}` of sections and blocks,
- Twig syntax and the [sandbox](twig-sandbox.md): tags, filters, functions and methods a theme may use.
Every write keeps the previous version of the file with `CLI: ` as the author, so the code editor in the admin can restore it.
Writing `config/settings_data.json` also applies its `current` object to the theme's settings in the store - colours, fonts, widths, everything the theme editor sets. Those values live on the theme, not in the file, so this is how a file you send on purpose shows up on the storefront. Keys missing from your file keep their values. The response then has `settings_applied`, the list of settings that changed.
### `DELETE /themes/{id}/files/{path}`
```json
{ "deleted": "snippets/old-card.twig" }
```
`theme.json` and `layout/theme.twig` cannot be deleted (`422`).
## Check
### `POST /check`
Runs a whole theme through the save rules without touching any theme in the store, plus checks for common mistakes (missing `content_for_header`, missing brand tokens, sections without `section.attributes`). This is `shopdepot theme check`.
```json
{
"files": { "theme.json": "{ ... }", "layout/theme.twig": " ..." },
"binaries": { "assets/fonts/body.woff2": 48211 }
}
```
`files` holds text files with their content; `binaries` holds paths and sizes of images and fonts (their content is not needed).
```json
{
"errors": 1,
"warnings": 1,
"problems": [
{ "path": "sections/content/hero.twig", "level": "error", "message": "Unexpected \"}\" (line 12)" },
{ "path": "sections/content/hero.twig", "level": "warning", "message": "the root element does not print {{ section.attributes }} - the theme editor cannot select the section." }
]
}
```
## Building a theme from the store's data
These calls help a tool (ShopDepot Studio, your own scripts) map an existing site onto sections and fill them with the store's real data.
### `GET /themes/{id}/sections`
Every section and block that can be placed in this theme: the platform's core sections plus the theme's own files. Each entry has `key` (`sections/faq`), `kind` (`sections` or `blocks`), `type`, `name`, `source` (`core` or `theme`), `doc`, `settings` (`id:type`), `blocks`, `presets` and `targets`. A theme file with the same name as a core section replaces it and has `overrides_core: true`.
### `GET /sample`
A small sample of the store's data to wire sections to: `categories` (`handle`, `name`, `depth`, `url` and what the merchant set for the category - see below), `menus` (`handle`, `name`) and published `offers` (`handle`, `title`, `url`), plus `category_count` and `offer_count`. No customers, orders or purchase prices.
Each category also says what it has, so you can pick one to check a banner, an icon or the text below the products:
```json
{ "handle": "serums", "name": "Serums", "depth": 1, "url": "https://example.myshopdepot.pl/categories/serums/",
"heading": "Face serums", "image": "https://cdn.example/m/…/serums_480.webp", "icon": null, "icon_vector": false,
"has_description": true, "has_additional_description": false }
```
`heading` is the H1 set in the admin (null when the page uses the name), `image` a 480 px thumbnail of the category image, `icon` the icon (`icon_vector` for an SVG), `has_description` and `has_additional_description` whether there is text. In templates the same data is [`category`](../reference/objects/category.md).
### `POST /media`
Uploads a file to the store's file library - a multipart request with the file in a field named `file`. Use it for videos, large photos and banners: a theme's `assets/` folder accepts only images and fonts up to 2 MB. The same rules apply as for uploads in the admin (file types, size limits, SVG cleaned or refused, the same file uploaded twice is stored once). Answers `201`:
```json
{ "media": { "id": "…", "kind": "video", "mime": "video/mp4", "name": "hero.mp4", "url": "https://cdn.…/hero.mp4" } }
```
Point a `video` or `image_picker` setting of a section at the file with its `id`.
## Reference theme
### `GET /starter.zip`
The latest published version of `base`, the reference theme, as a ZIP. The `X-Theme-Version` header carries its version. `shopdepot theme init` starts from it.
---
# Theme architecture
Source: https://shopdepot.dev/docs/themes/architecture/
A storefront page is built in layers. Each layer has one job, and the merchant controls the parts in the middle.
```text
layout/theme.twig the HTML shell: , 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 `` - 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.
```twig
{{ page_title ? page_title ~ ' - ' ~ shop.name : shop.name }}
{{ 'css/theme.css'|asset_url|stylesheet_tag }}
{{ render('brand-tokens') }}
{{ content_for_header }}
{{ sections('header-group') }}
{{ content_for_layout }}
{{ sections('footer-group') }}
{{ 'js/theme.js'|asset_url|script_tag }}
```
The platform replaces your `` with the title from the store's SEO settings, so write a sensible fallback and do not worry about it further. See [SEO](seo.md).
## Templates
A template is JSON: a list of sections with their settings and blocks, and their order. There is no Twig in `templates/`.
```json
{
"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](templates.md).
## 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](platform-pages.md#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](../reference/core-sections.md).
## Data
Templates never see the database. The controller of each page hands over [objects](../reference/objects/index.md) - `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](../reference/page-types.md).
## 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](performance.md) covers the rules.
---
# File structure
Source: https://shopdepot.dev/docs/themes/file-structure/
A theme is one folder. The same paths are used everywhere - in your repository, in the ZIP, in the code editor in the store admin and in the store's database - so a file has one identity from your editor to production.
```text
example/
├── theme.json the manifest (name, handle, version, listing, menus, widgets)
├── layout/
│ └── theme.twig the HTML shell of every page
├── templates/ JSON only - which sections each page shows
│ ├── index.json product.json category.json page.json blog.json article.json
│ ├── search.json cart.json contact.json terms.json term.json 404.json
│ ├── product.mask.json an alternate template (after the dot)
│ └── category.books.json an alternate category template
├── sections/ Twig + {% schema %}, folders allowed
│ ├── header-group.json section groups sit at the top of sections/
│ ├── footer-group.json
│ ├── layout/ header.twig footer.twig announcement-bar.twig
│ ├── product/ main-product.twig product-reviews.twig
│ └── content/ hero.twig featured-products.twig
├── blocks/ theme blocks: {% schema %} required
│ ├── shared/_group.twig a leading underscore marks a system block
│ └── product/ price.twig buy-buttons.twig variant-picker.twig
├── snippets/ partials: {% doc %}, no schema
│ └── product-card.twig icon.twig brand-tokens.twig
├── assets/ CSS, JS, fonts, images - folders allowed
│ ├── css/ js/ fonts/ img/
├── config/
│ ├── settings_schema.json theme settings (or config/settings/*.json)
│ └── settings_data.json starting values of those settings
├── locales/
│ ├── en.default.json storefront texts, the fallback language
│ └── pl.json
└── demo/ data of the theme's demo store (theme store only)
```
## The rules
Every file is checked when it is written - by an upload, the code editor or a package publish. A rule that fails stops the save with a message; nothing is checked later at render time.
| Rule | What it means |
| --- | --- |
| **Ten names** | Only `theme.json`, `layout/`, `templates/`, `sections/`, `blocks/`, `snippets/`, `assets/`, `config/`, `locales/` and `demo/` are part of a theme. Everything else in your folder - `README.md`, `package.json`, `src/`, `node_modules/` - stays local and is skipped by an upload. Build tools write their output to `assets/`. |
| **Lowercase paths** | Letters `a-z`, digits, `.`, `_` and `-`. A file name may start with `_`, a folder may not. |
| **Four levels at most** | `assets/img/icons/cart.svg` is fine, `assets/img/icons/ui/cart.svg` is not. |
| **Names, not paths** | Sections, blocks and snippets are referenced by file name without folder or extension - `"type": "main-product"`, `render('product-card')`. Folders are for you; move a file between them and nothing breaks. |
| **Unique names** | Because of that, a section, block or snippet name must be unique across the whole theme. Two `card.twig` in different folders is an error - name them by domain: `product-card`, `article-card`. |
| **Blocks have schemas, snippets do not** | A file in `blocks/` must declare `{% schema %}`. A file in `snippets/` must not. |
| **Templates are JSON** | `templates/` and `sections/*-group.json` hold JSON only. |
| **Valid JSON** | Templates, section groups, `config/*`, `locales/*`, `theme.json` and `demo/*.json` must parse. |
| **Size** | 256 KB per text file, 2 MB per binary file. |
| **Binaries in assets** | Images and fonts (`png`, `jpg`, `jpeg`, `gif`, `webp`, `avif`, `ico`, `woff`, `woff2`, `ttf`, `otf`, `eot`) only under `assets/` or `demo/assets/`. SVG is text and may sit anywhere in `assets/`. |
> [!WARNING]
> An upload does not fail on a file outside the contract - it **skips** it and lists it. A font in `assets/Fonts/` or an image four folders deep silently goes missing and returns 404 in the store. Read the list after every upload.
## Naming conventions
The platform does not enforce these, but the theme store review does:
- English file names in kebab-case.
- `main-*` for the section that renders the main object of a page: `main-product`, `main-category`, `main-cart`.
- A leading underscore for system blocks the merchant does not add on their own: `_group`.
- Snippets named by what they show: `product-card`, `cart-line`, `price`.
## Settings split across files
A long settings schema can be split: instead of `config/settings_schema.json`, put one group per file in `config/settings/` - `10-colors.json`, `20-typography.json`. Files are merged in name order, hence the numeric prefixes. Use one form or the other, not both.
## `settings_data.json` is a starting point
`config/settings_data.json` in your package holds the values a store starts with when it installs your theme. After that the merchant's values live with their store: a new version of your theme keeps every value they set, adds new settings with your defaults and parks removed ones, so a rollback can bring them back. See [Settings](settings.md#updates).
---
# theme.json
Source: https://shopdepot.dev/docs/themes/theme-json/
`theme.json` at the top of the theme says what the theme is. The theme store reads its listing and price from here, and installing the theme creates the menus and widgets it declares.
```json
{
"name": "Example",
"handle": "example",
"version": "1.4.0",
"author": "Example Studio",
"license": "Commercial",
"description": "A calm theme for small catalogues.",
"summary": "Calm and fast, for stores with up to a few hundred products.",
"categories": ["home", "minimal"],
"preview": { "background": "#faf6f1", "accent": "#b4543a", "text": "#231b16" },
"catalog": {
"tagline": "A calm storefront that lets the products talk",
"highlights": ["Mega menu with featured product", "Sticky add to cart", "Two-column product page"],
"docs_url": "https://example.com/docs",
"support_url": "https://example.com/support"
},
"pricing": { "model": "one_time", "amount": 24900, "currency": "PLN" },
"requires": { "shopdepot": ">=1.0" },
"menus": { },
"widgets": { }
}
```
## Identity
| Key | Required | Description |
| --- | --- | --- |
| `name` | yes | Display name. |
| `handle` | yes | Lowercase letters, digits and dashes, up to 63 characters. Identifies the theme in the registry for good - choose it once. |
| `version` | yes | A semantic version (`1.4.0`). Every upload needs a new one; a version is never overwritten. |
| `author` | | Your name or studio. |
| `license` | | `MIT`, `Commercial` or another identifier. |
| `description` | | One or two sentences for the theme library. |
| `summary` | | A shorter line for the catalogue card. |
| `categories` | | Catalogue categories, for filtering. |
| `preview` | | Three colours - `background`, `accent`, `text` - for the catalogue tile when there is no screenshot. |
| `requires.shopdepot` | | The platform version range the theme needs. |
## Catalogue listing
`catalog` is the theme store page. It travels **inside the package** on purpose: the store shows what the version you uploaded says, and changing the listing means uploading a new version. Screenshots are the one exception - they are files, uploaded to the listing separately.
| Key | Description |
| --- | --- |
| `tagline` | One sentence under the name. |
| `highlights` | Five or six short lines - what the theme does well. |
| `screenshots` | Screenshot addresses. Usually left out - screenshots are uploaded to the listing by the theme store team. |
| `demo` | Handle of the theme's demo store, when it differs from the theme handle - see [Publishing](publishing.md#demo-store). |
| `docs_url` | Your documentation for merchants. |
| `support_url` | Where merchants get help. |
## Pricing
| Key | Description |
| --- | --- |
| `model` | `free`, `one_time` or `subscription`. |
| `amount` | Price in minor units - `24900` is 249.00. |
| `currency` | ISO code, for example `PLN`. |
| `period` | For subscriptions: `month` or `year`. |
A paid theme installs into any store as a **trial**: the merchant can preview it but not publish or edit it until they buy a licence for that store. See [Publishing](publishing.md#trials-and-licences).
## Menus
A theme declares **menu placements** - the places in its layout where a menu goes - with default contents. Installing the theme creates the menus a store does not have yet and assigns them; the merchant can then point any placement at any menu.
```json
"menus": {
"header": {
"label": "t:menus.header.label",
"handle": "main-menu",
"title": "t:menus.header.title",
"links": [
{ "title": "t:menus.links.home", "type": "home" },
{ "title": "t:menus.links.shop", "type": "category", "target": "all",
"panel": { "mode": "links", "source": "categories", "depth": 2, "hide_empty": true } },
{ "title": "t:menus.links.blog", "type": "blog" },
{ "title": "t:menus.links.contact", "type": "url", "target": "/contact/" }
]
},
"footer": {
"label": "t:menus.footer.label",
"handle": "footer",
"links": [{ "type": "pages", "limit": 6 }]
}
}
```
A section reads a placement with a `link_list` setting whose value is the placement's `handle`. Link types, panels and the lazy menu levels are described in [Menus and widgets](menus-and-widgets.md).
## Widgets
A widget is a **named, configured instance of one of your sections** that the merchant fills once and shows in many places - customer testimonials, a video wall, a store promise. Declare the placements and their default contents; installation creates the missing widgets and never overwrites a merchant's.
```json
"widgets": {
"testimonials": {
"label": "t:widgets.testimonials.label",
"handle": "testimonials",
"name": "t:widgets.testimonials.name",
"type": "testimonials",
"settings": { "heading": "t:widgets.testimonials.heading" },
"blocks": {
"one": { "type": "testimonial", "settings": { "quote": "…", "author": "…" } }
},
"block_order": ["one"]
}
}
```
`settings` and `blocks` have exactly the shape of a section entry in a JSON template. See [Menus and widgets](menus-and-widgets.md#widgets).
## Translated values
Any text value that starts with `t:` is a translation key from `locales/`, resolved in the store language at installation - `"t:menus.links.home"`. See [Translations](translations.md).
---
# Templates
Source: https://shopdepot.dev/docs/themes/templates/
A template decides which sections a page type shows. Templates are JSON only, in `templates/`, one per [page type](../reference/page-types.md).
## Format
```json
{
"sections": {
"main": {
"type": "main-product",
"settings": { "gallery_layout": "auto", "show_breadcrumbs": true },
"blocks": {
"title": { "type": "product-title" },
"price": { "type": "price", "settings": { "show_lowest_30d": true } },
"buy": { "type": "buy-buttons" }
},
"block_order": ["title", "price", "buy"]
},
"reviews": { "type": "product-reviews", "settings": { "limit": 10 } }
},
"order": ["main", "reviews"]
}
```
- `sections` - entries keyed by an id you choose, unique in the file. `type` is the file name of a section.
- `settings` - values for the section's schema settings. Missing ones take the schema default.
- `blocks` and `block_order` - the blocks inside a section, the same shape again, nested as deep as the blocks allow.
- `order` - the order of sections on the page.
- `"disabled": true` on an entry keeps it in the file but does not render it.
The merchant's arrangement from the theme editor is stored with their store and wins over the file. Your file is what a new installation starts with - and what the editor offers to reset to.
## Page types
Each storefront page type has a template and receives its own variables: `product.json` gets a `product`, `category.json` a `category` with its listing, `cart.json` the visitor's `cart`. The full list, with addresses and variables, is in [Page types](../reference/page-types.md).
A store page without a template in your theme falls back to the platform's built-in rendering, so ship every type `base` ships.
### The category page
Besides the name and the listing, a store category carries what the merchant set in **Catalog → Categories**: the page heading, a description, an image, an icon and a second description. All of them are optional, so test each one for emptiness:
```twig
{% set c = category %}
{{ c.heading }}
{% if c.description %}{{ c.description|raw }}
{% endif %}
{% if c.image and pagination.page|default(1) == 1 %}
{{ c.image|image_url(width: 2400)|image_tag(alt: c.image.alt, loading: 'eager', fetchpriority: 'high', sizes: '100vw') }}
{% endif %}
{# the listing #}
{% if c.additionalDescription and pagination.page|default(1) == 1 %}
{{ c.additionalDescription|raw }}
{% endif %}
```
- `heading` is the H1 of the category page (the name when the merchant left it empty). Use `title` in menus, tiles and breadcrumbs.
- `image` is a banner or a tile picture. On the category page it is usually above the fold, so it loads eagerly with `fetchpriority: 'high'`.
- `additionalDescription` is longer text for below the products: a buying guide, an FAQ, SEO text. Show it on the first page of the listing only, so the same text is not repeated on `?page=2`.
- `icon` is a small picture for menus and chips. It can be an SVG (`icon.vector`), which you can draw as a CSS mask so it takes the text colour. It is decorative, so give it an empty `alt`.
Both descriptions are HTML cleaned by the platform, so print them with `|raw`. The same image and icon come in [`children.json`](menus-and-widgets.md#menu-levels-on-demand) for menus loaded on demand. Every field is in the [`category`](../reference/objects/category.md) reference.
## Alternate templates
Some pages can use a different template than the default one of their type. The alternate goes after a dot:
| File | Used for |
| --- | --- |
| `product..json` | Offers whose template the merchant set to `` on the offer page. Every `product.*.json` in the published theme appears in that list. |
| `category..json` | Store categories whose template the merchant set to `` in **Catalog → Categories**. The choice belongs to one category: its subcategories stay on `category.json` until they pick their own. |
| `page..json` | The page at that address - `page.contact-us.json` renders `/contact-us/` and `/help/contact-us/`. |
| `terms..json`, `term..json` | The index and value pages of one feature - `terms.authors.json`. |
A suffix that does not exist in the theme renders the default template, so removing an alternate never breaks a page.
## Section groups
`sections/header-group.json` and `sections/footer-group.json` hold the sections around every page, in the same format with a `type`:
```json
{
"type": "header",
"sections": {
"announcement": { "type": "announcement-bar", "settings": { "text": "Free delivery over 199 PLN" } },
"header": { "type": "header", "settings": { "menu": "main-menu" } }
},
"order": ["announcement", "header"]
}
```
The layout renders a group with `{{ sections('header-group') }}`. Section groups sit directly in `sections/`, not in a subfolder, and their names end with `-group.json`.
## Limits
Keep a template to a reasonable number of sections - each one is rendered and cached separately, and every extra band is weight on the page. The theme store review looks at the default templates of your theme.
---
# Sections and blocks
Source: https://shopdepot.dev/docs/themes/sections-and-blocks/
Sections and blocks are what the merchant works with in the theme editor. A section is a band of a page; a block is a piece inside a section or inside another block.
## A section
```twig
{# sections/content/image-with-text.twig #}
{% set s = section.settings %}
{% if s.image %}
{{ s.image|image_url(width: 1600)|image_tag(alt: s.image.alt, sizes: '(min-width: 900px) 50vw, 100vw') }}
{% else %}
{{ placeholder_svg('image', 'iwt__placeholder') }}
{% endif %}
{{ content_for('blocks') }}
{% stylesheet %}
.iwt { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap, 24px); }
.iwt--image-right .iwt__media { order: 2; }
{% endstylesheet %}
{% schema %}
{
"name": "t:sections.image_with_text.name",
"settings": [
{ "type": "image_picker", "id": "image", "label": "t:sections.image_with_text.image" },
{ "type": "select", "id": "layout", "default": "image-left", "label": "t:sections.image_with_text.layout",
"options": [
{ "value": "image-left", "label": "t:sections.image_with_text.left" },
{ "value": "image-right", "label": "t:sections.image_with_text.right" }
] }
],
"blocks": [{ "type": "@theme" }],
"presets": [
{
"name": "t:sections.image_with_text.name",
"blocks": {
"heading": { "type": "text", "settings": { "text": "Made to last", "size": "xl" } },
"cta": { "type": "button", "settings": { "label": "Shop now", "url": "/categories/all/" } }
},
"block_order": ["heading", "cta"]
}
]
}
{% endschema %}
```
Three things every section does:
- **`{{ section.attributes }}` on the root element.** The theme editor uses these attributes to select the section in the preview.
- **Settings through `section.settings`**, already resolved: an `image_picker` gives a [file](../reference/objects/file.md), a `product` setting a [product](../reference/objects/product.md). An empty setting is `null`.
- **Blocks with `{{ content_for('blocks') }}`**, where they belong in your markup.
## The schema
| Key | Description |
| --- | --- |
| `name` | Name in the editor, usually a `t:` key. |
| `settings` | The settings - see [Settings](settings.md) and [Setting types](../reference/setting-types.md). |
| `blocks` | Which blocks the section accepts. A non-empty list is what tells the editor the section takes blocks at all - see below. |
| `presets` | Ready configurations the merchant picks from "Add section". A section without a preset can only be placed in templates by you. |
| `targets` | Where the block content editor offers the section or block: `page`, `post`, `offer`, `email`. Without it, it is a theme-only section. |
| `group` | A category in the "Add section" list, for example `content`. |
## Blocks
Theme blocks live in `blocks/` and must declare a schema. They render the same way as sections, with `block` instead of `section`:
```twig
{# blocks/text.twig #}
{% set size = block.settings.size|default('lg') %}
{{ block.settings.text }}
{% schema %}
{
"name": "t:blocks.text.name",
"settings": [
{ "type": "inline_richtext", "id": "text", "label": "t:blocks.text.text", "default": "Text" },
{ "type": "select", "id": "size", "default": "lg", "label": "t:blocks.text.size",
"options": [{ "value": "xl", "label": "XL" }, { "value": "lg", "label": "L" }, { "value": "md", "label": "M" }] }
]
}
{% endschema %}
```
### Which blocks a section accepts
| Entry in `blocks` | Means |
| --- | --- |
| `{ "type": "@theme" }` | Any theme block in `blocks/` (and the core blocks). |
| `{ "type": "@app" }` | Blocks from apps, when apps arrive. Declaring it now costs nothing. |
| `{ "type": "faq-item" }` | A block meant for this section. List several to describe a set. |
### Nesting
A block can accept blocks too - declare `blocks` in its schema and print `{{ content_for('blocks') }}`. That is how layout blocks work: base ships `_group`, a flex container with direction, gap and alignment settings, and the merchant composes columns and rows from it without you writing each combination. Blocks nest up to four levels.
A block that is listed by name in a parent's `blocks` is a **child block** - it is meant to live inside that parent only (`faq-item` inside `faq`). Child blocks do not declare `targets`.
### Private and system blocks
A file name starting with an underscore - `_group.twig` - marks a system block: available for nesting, but not offered as a standalone item in the editor's list.
## Styles and scripts
`{% stylesheet %}` in a section or block is collected, with every other one in the theme, into a single `_sections.css` that the platform links in `content_for_header`. The CSS loads once, however many times the section appears, and is cached with the theme version.
`{% javascript %}` is collected into `_sections.js` the same way, but that file is not linked for you. Prefer a module in `assets/` loaded from the layout; see [Assets](assets.md).
Style sections with the [brand tokens](platform-pages.md#brand-tokens) (`var(--color-accent)`, `var(--radius)`) and your own custom properties, not hard-coded colours - the merchant changes the tokens in theme settings and expects every section to follow.
## Documenting snippets and blocks
`{% doc %}` holds the parameters a snippet expects. It never renders, but it is how the next developer - and the linter that is coming - knows how to call it:
```twig
{% doc %}
@param product - the product to show
@param show_rating - optional, show stars under the title
{% enddoc %}
```
## The core library
The platform ships sections and blocks to every theme, under your files:
- Sections - `content`, `banner`, `media-text`, `callout`, `hero-tiles`, `product-list`, `term-grid`, `logo-wall`, `newsletter`, `testimonials`, `post-list`, `faq`, `contact-form`.
- Blocks - `heading`, `paragraph`, `image`, `button`, `list`, `quote`, `columns`, `divider`, `spacer`, `html` and the child blocks of the sections above.
They style themselves only with brand tokens, with fallbacks, so they look right in any theme. **Your file with the same name replaces the core one**: ship `sections/faq.twig` and the store uses yours, and the core CSS of `faq` is no longer loaded. Keep the setting ids of the core file when you do, so the merchant's content carries over. Settings and blocks of every core file are listed in [Core sections and blocks](../reference/core-sections.md).
When a merchant switches themes, a section type the new theme does not know becomes a placeholder that keeps its settings, and comes back when the type is available again. Content is never lost.
## Data inside a section
A section gets the variables of the page it is on (`product` on an offer page, `category` on a category page) plus the globals. When a section needs data the page does not give it - bestsellers on the home page, posts on a product page - it asks for it with the data functions: `query_products()`, `query_posts()`, `query_terms()`, `query_categories()`. They always read the current store. See [Functions](../reference/functions.md#data).
---
# Settings
Source: https://shopdepot.dev/docs/themes/settings/
Settings are the fields the merchant fills in the theme editor. You declare them in a schema; the platform builds the form, validates input and hands resolved values to your templates.
## Theme settings
Theme-wide settings - colours, fonts, logo, page width - live in `config/settings_schema.json`, a list of groups:
```json
[
{
"name": "theme_info",
"theme_name": "Example",
"theme_version": "1.4.0",
"theme_author": "Example Studio",
"theme_documentation_url": "https://example.com/docs"
},
{
"name": "t:settings.colors.name",
"settings": [
{ "type": "color", "id": "color_background", "default": "#fafafa", "label": "t:settings.colors.background" },
{ "type": "color", "id": "color_accent", "default": "#0f0f0f", "label": "t:settings.colors.accent" }
]
},
{
"name": "t:settings.layout.name",
"settings": [
{ "type": "range", "id": "page_width", "min": 1000, "max": 1800, "step": 20, "unit": "px", "default": 1440, "label": "t:settings.layout.page_width" },
{ "type": "range", "id": "radius", "min": 0, "max": 24, "step": 1, "unit": "px", "default": 0, "label": "t:settings.layout.radius" }
]
}
]
```
Templates read them from the global `settings`: `{{ settings.page_width }}`. A long schema can be split into `config/settings/*.json` - see [File structure](file-structure.md#settings-split-across-files).
## Section and block settings
Sections and blocks declare settings in the `settings` array of their `{% schema %}`, with the same types. Read them as `section.settings.` and `block.settings.`.
## A setting
| Key | Required | Description |
| --- | --- | --- |
| `type` | yes | One of the [setting types](../reference/setting-types.md). |
| `id` | yes | Unique within its schema - `snake_case`. It is the key in templates and in stored values: **never rename it** in a released theme, or every store loses that value. |
| `label` | yes | Field label, usually a `t:` key. |
| `default` | | The starting value. Without it a setting is empty - `null`, or `false` for a checkbox. |
| `info` | | Help text under the field. |
| `placeholder` | | Placeholder for text fields. |
| `options` | for `select` | A list of `{ value, label }`. |
| `min`, `max`, `step`, `unit` | for `range` | The slider bounds; values outside them are clamped. |
| `content` | for `header`, `paragraph` | The text shown in the editor. |
| `limit` | for `store_reviews` | How many reviews. |
## Resolved values
The platform does the lookup work before your template runs. A `product` setting gives a [product](../reference/objects/product.md) object, a `category_list` a list of categories, a `link_list` a [menu](../reference/objects/menu.md), an `image_picker` a [file](../reference/objects/file.md) you pass straight to `|image_url`. An offer that was deleted later simply drops out. Write templates for the empty case:
```twig
{% if section.settings.product %}
{{ render('product-card', { product: section.settings.product }) }}
{% endif %}
```
`richtext` and `html` values are sanitised when the merchant saves them **and** when they are read, so `{{ section.settings.text|raw }}` is safe even for values that came from your package.
## Validation
Input is checked against the schema when the merchant saves: numbers are clamped to the range, a `select` value must be one of the options, a colour must be `#rrggbb`, a URL must be a store path or an `http(s)`, `mailto:` or `tel:` address. Settings that are not in the schema are dropped. You never need to defend a template against a value the schema does not allow.
## Starting values
`config/settings_data.json` holds the values a store starts with:
```json
{
"current": {
"color_background": "#fafafa",
"page_width": 1440
}
}
```
## Updates
When a store updates to a new version of your theme:
- every value the merchant set is kept,
- new settings arrive with their defaults,
- settings you removed are parked, not deleted, so rolling back brings them back.
That is why `id`s are forever. To change what a setting means, add a new one.
---
# Translations
Source: https://shopdepot.dev/docs/themes/translations/
A theme speaks the language of the store it is installed in. Texts live in `locales/`, never in templates.
## Locale files
```text
locales/
├── en.default.json the fallback - every key must exist here
└── pl.json one file per language, same keys
```
```json
{
"cart": {
"title": "Cart",
"empty": "Your cart is empty",
"items": "{{ count }} items"
}
}
```
The store language decides the file; a key missing in it falls back to `*.default.json`.
## In templates
```twig
{{ 'cart.title'|t }}
{{ 'cart.items'|t({ count: cart.itemCount }) }}
```
Parameters replace `{{ name }}` (or `%name%`) in the text.
## In JSON
Any text value in a schema, a template, `theme.json` or `settings_data.json` can be a key with the `t:` prefix - `"label": "t:sections.hero.name"`. Editor labels and default contents of menus and widgets are translated this way when the theme is installed, so a store gets its menus in its own language.
## What not to translate
Content the merchant writes - product names, page text, setting values - is theirs and is not part of `locales/`. Translate only what your theme itself puts on the page: buttons, labels, empty states, accessibility texts like "Skip to content".
---
# The Twig sandbox
Source: https://shopdepot.dev/docs/themes/twig-sandbox/
Theme templates run in a Twig sandbox. A theme is code from outside the platform rendered for every visitor of a store, so the sandbox decides exactly what it can reach: the data of **this** store, through read-only objects, and nothing else.
## What is allowed
- The [tags](../reference/tags.md): `if`, `for`, `set`, `apply`, `with`, `verbatim`, `do`, plus the theme tags `schema`, `stylesheet`, `javascript` and `doc`.
- The [filters](../reference/filters.md): common Twig filters and the ShopDepot ones - `money`, `image_url`, `asset_url`, `t` and others.
- The [functions](../reference/functions.md): rendering (`content_for`, `render`, `sections`, `render_widget`), platform components, data queries and `url_for`.
- Reading [objects](../reference/objects/index.md) and calling their methods.
Everything else is refused. A template that uses something outside these lists **does not save** when you write it with the code editor, the [CLI](cli.md) or the [theme API](theme-api.md) - the error comes back with the file name and line, not on a live page. A ZIP upload is checked for syntax and the file contract; run `shopdepot theme check` before you upload one, so sandbox errors do not wait until a page renders.
## What is not allowed, and what to use instead
| Not available | Use instead |
| --- | --- |
| `{% extends %}`, `{% block %}` | One layout (`layout/theme.twig`) around JSON templates. |
| `{% include %}` tag, `{% macro %}`, `{% import %}`, `{% embed %}` | Snippets: `{{ render('snippet-name', { … }) }}`. |
| Reading object properties directly | Getters through the dot: `product.title`. |
| PHP functions, files, the network, `{% sandbox %}`, `{% use %}` | The [data functions](../reference/functions.md#data) for store data, the [JSON APIs](javascript-apis.md) in the browser. |
| Filters and functions not in the reference | Ask for them - if a theme needs something often, it belongs in the platform. |
## Objects only
The sandbox allows method calls on platform objects and on nothing else. Arrays and hashes - `section.settings`, `cart.discounts` entries, `pagination` - are read with the dot as usual. Entities, services and repositories never reach a template, so a theme cannot read another store's data or call anything that writes.
## Names are camelCase
Object fields are getters, and Twig maps `product.featuredMedia` to `getFeaturedMedia()`. Write the camelCase name from the reference. `product.featured_media` does not exist and prints nothing.
## Escaping
Output is escaped as HTML automatically. Use `|raw` only for HTML the platform already sanitised - offer descriptions, page and post content, `richtext` and `html` settings, `panelHtml` of a menu link. Never put `|raw` on text from a setting of another type, a URL or a translation that takes parameters.
To pass data to a script, build a hash of the values you need - objects themselves do not serialise - and escape it for the attribute:
```twig
```
## Undefined values
Variables that do not exist are empty, not errors - `{{ product.subtitle }}` on a field that does not exist prints nothing. That keeps a page alive when data is missing, and it also hides typos. Check names against the reference.
## Snippets have their own scope
`render()` gives a snippet only what you pass, plus `shop`, `settings` and `cart`. Variables of the calling section do not leak in, so a snippet behaves the same wherever it is used:
```twig
{# in a section #}
{% for item in products %}
{{ render('product-card', { product: item, show_rating: section.settings.show_rating }) }}
{% endfor %}
```
A missing snippet renders nothing instead of breaking the page.
## When a section fails
An error while rendering one section - a division by zero, a broken loop - is logged and that section renders empty. The rest of the page is served. Watch for empty bands in preview; the code editor shows syntax errors before they get that far.
---
# Assets and fonts
Source: https://shopdepot.dev/docs/themes/assets/
Everything the browser loads from your theme lives in `assets/`, in folders if you like: `assets/css/theme.css`, `assets/js/theme.js`, `assets/fonts/`, `assets/img/`.
## Referencing an asset
`asset_url` takes the path **inside** `assets/`:
```twig
{{ 'css/theme.css'|asset_url|stylesheet_tag }}
{{ 'js/theme.js'|asset_url|script_tag }}
```
The address contains a fingerprint of the theme version and is served from the store CDN with a cache lifetime of a year. A new version of your theme gets a new fingerprint, so browsers fetch the changed files at once and nothing ever needs a cache-busting query string.
In CSS, use relative paths between files in `assets/` - `url("../fonts/example.woff2")` from `assets/css/theme.css`.
## JavaScript
Ship plain ES modules. `script_tag` produces `