Files, images and themes
A file the platform serves is never just a file: it belongs to an owner, and the owner decides both where it is stored and at which address a visitor can fetch it. There are two owners — a site and a theme — and two more places files appear: a gallery, whose pictures are attached to a record, and a theme's layouts, which are not files at all but rows.
| Owner | Resources | Served at |
|---|---|---|
| The site | assets |
/assets/<ownerId>/… |
| A theme, per file | images, scripts, stylesheets |
Managed as folders and files; the addresses below serve the mirrored copy |
| A theme, in bulk | theme-files |
/css/…, /js/…, /images/… of the active theme |
| A gallery | galleries |
/galleries/<galleryId>/images/<sizeSlug>/<filename> |
Content files
assets is the site's own file manager: pictures and documents that content points at, arranged in
folders. Every call names the owner explicitly — for this resource the owner is the site itself:
curl "$ADMIN_API/api/assets/?ownerId=$SITE_ID&path=/" -b cookies.txt
{
"success": true,
"data": {
"path": "/",
"folderId": "…",
"folders": [{ "folderId": "…", "name": "press", "path": "/press/" }],
"files": [
{
"fileId": "…",
"filename": "logo.svg",
"contentType": "image/svg+xml",
"size": 4812,
"isImage": true,
"editable": false,
"url": "/assets/<ownerId>/logo.svg"
}
]
}
}
isImage and editable are extension answers, not a guess about the content. An image is one of
jpg, jpeg, png, gif, bmp, svg, webp, ico; editable is true for the text formats the
manager hands back as a string — js, css, html, htm, txt, json, xml, md.
Writing into it:
| Call | Body | Answers |
|---|---|---|
POST /api/assets/upload?ownerId=&path=/ |
multipart, one file part | { filename, url, isImage, editable } |
POST /api/assets/delete |
{ ownerId, path, filename } |
{ success: true } |
POST /api/assets/create-folder |
{ ownerId, path, name } |
{ folderId, path } |
POST /api/assets/edit-folder |
{ ownerId, path, name } |
{ path } — the new path |
POST /api/assets/delete-folder |
{ ownerId, path } |
Deletes the folder with its files and subfolders. The root folder cannot be deleted |
path is the folder the operation applies to, / for the root. A folder path ends with a slash.
Uploading a name that already exists in that folder replaces the file and updates its size, content
type and hash instead of creating a second row.
An owner that names no site is refused before anything is written — the answer is a bad parent, with
the message site <id> does not exist. A folder nobody owns has no route back to it, and such
folders used to accumulate one per client-supplied identifier.
Reading a content file
A file is fetched from the site's own domain, through its folder owner:
| Address | Answers |
|---|---|
/assets/<ownerId>/<filename> |
The original bytes, as uploaded |
/assets/<ownerId>/<sizeSlug>/<filename> |
The picture resized for that size |
/assets/<ownerId>/<folder>/<sizeSlug>/<filename> |
The same, for a picture in a folder |
ownerId is the folder's owner. For assets that is the site identifier itself — the same value
you passed as ownerId when listing the folder — while a theme's own folders are owned by the theme,
which is why the address is built from the owner you listed and not assumed from the site.
A request for a size the active theme does not declare answers 404; there is no default size and
no silent fallback. A non-image asset (a PDF, a document) is streamed through untouched: no resize
engine can process it, and the address without a size slug is the only one that answers.
Sizes and how a picture is delivered
Sizes are a property of the theme, not of a file and not of a site setting: every picture served
at a sizeSlug is resized according to the theme that is active for the request's site.
The theme row carries one JSON column, ImageSizes:
{
"imageSizes": [
{ "slug": "card", "manipulationType": 4, "maxWidth": 600, "maxHeight": 400, "quality": 80 },
{ "slug": "og", "manipulationType": 1, "maxWidth": 1200, "maxHeight": 630 }
],
"watermarks": []
}
| Key | Meaning |
|---|---|
slug |
The path segment in the address — the only name a template ever uses |
manipulationType |
1, 2 and 3 fit inside the box, 4 fills it and crops, anything else lets the engine choose |
maxWidth / maxHeight |
The box. 0 or absent means "no bound on this side" |
quality |
Encoder quality for the produced variant |
How the bytes reach the client is a deployment decision, not a page decision: with an image proxy
configured the site answers 302 to a signed proxy URL, and without one it resizes in process and
sends the bytes. The address is the same either way.
Gallery pictures
A gallery is a set of pictures attached to a record — a product, a page, a post — under one field name. Pictures arrive through their own upload endpoint, which takes them for a site and answers an identifier:
curl -X POST "$ADMIN_API/api/galleries/upload" \
-b cookies.txt \
-F 'siteId=<site-id>' \
-F 'file=@photo.jpg'
# { "success": true, "data": { "imageId": "…" } }
Only pictures are accepted, by extension: jpg, jpeg, png, gif, webp, bmp, svg, avif.
A file above the upload limit answers 413; the limit is 20 MiB unless the deployment sets
GALLERY_MAX_UPLOAD_BYTES.
imageId is not yet a gallery picture. The upload lands in a temporary area, and the picture becomes
one when the record is saved with it — so an upload that is never attached is garbage, swept after
24 hours (the window is UPLOAD_CACHE_TTL_HOURS). The sweep runs opportunistically, after an upload:
a failed sweep never fails the upload you made, it just leaves the row for the next one.
A gallery picture is addressed by the sequence number in its file name — 001.jpg is picture 1,
and the address carries the file name itself:
GET /galleries/<galleryId>/images/<sizeSlug>/<filename>
galleryId is the gallery identifier as 32 hexadecimal characters, without dashes. A file name that
starts with no number — or with 0 — answers 404, as do an unknown gallery and an undeclared size;
the size is resolved from the same theme imageSizes as a content file.
The admin side reads pictures back at GET /api/galleries/images/<imageId>?siteId=<site-id>, which
answers the original bytes, not a variant. That address exists because the public one needs a theme
size and lives on the site's domain, while an administrator is looking at a record that may not be
published yet.
Themes
A theme belongs to one site, and the site answers with it: a site may keep several themes and marks one of them active — the column lives on the site, so the same database can serve several sites with different themes. A theme row is created together with the site (a tenant without a theme cannot render), and the admin API updates it. In the admin API a theme is named by its uuid:
| Call | Answers |
|---|---|
GET /api/themes?siteId= |
The site's themes, a page at a time |
GET /api/themes/{id} |
One theme, with its sizes and settings |
POST /api/themes/save |
Updates an existing theme — ThemeId and Name are required, an unknown ThemeId answers 404 |
ImageSizes, SettingsData and SettingsMarkup travel as strings: they are JSON and markup the
theme owns, and the platform stores them verbatim.
Layouts
A layout is Liquid source, and it is a row of the theme, not a file. It is looked up by name, which is why the name matters more than anything else about it:
curl -X POST "$ADMIN_API/api/layouts/upload?themeId=<theme-id>" \
-b cookies.txt \
-F 'file=@content_page.liquid'
| Behaviour | Detail |
|---|---|
| Name | The file name without .liquid — content_page.liquid becomes content_page |
| Conflict | A layout of that name in that theme is replaced; a name that already exists cannot be created twice |
| Lookup | By that literal name, from Liquid ({% layout 'name' %}, {% include 'name' %}) and from the platform |
| Listing | GET /api/layouts/?themeId= |
| Editing | POST /api/layouts/save creates a layout or updates one by LayoutId. Creating a second layout of a name that theme already has answers 400; DELETE /api/layouts/{id} removes one |
The name is not slugified and not case-folded on the round trip: a layout called content_page is
content_page, and kebab-casing it would break every template that refers to it.
Three names are conventions the platform itself looks for:
| Layout | Used for |
|---|---|
| The page template's own layout | A content page renders the template's customDefaultLayout, and falls back to the template's alias when that layout does not exist |
error_500 |
The error page, when the theme provides one |
form_ajax_response |
The answer to a form submission from a browser, when the theme provides one (Forms and submissions) |
A render that finds no layout for a page is not an error page: the page falls through to whatever else answers that path.
Static files of a theme
A theme's css, js, images and nested fonts are served straight from the theme store, at the site's root:
| Address | Resolves to |
|---|---|
/css/<path> |
<active theme>/css/<path> |
/js/<path> |
<active theme>/js/<path> |
/images/<path> |
<active theme>/images/<path> |
/themes/<themeId>/css/<path> |
The same file on that named theme, whatever is active |
The bare form exists because a stylesheet's own url(/images/…) cannot know a theme identifier. In
this address themeId is written without dashes — 32 hexadecimal characters — which is not how the
admin API spells the same identifier, and not how a layout or a theme-file call takes it.
Cache-Control comes from the site's caching settings when the site declares them.
That store is reached through theme-files, which mirrors a directory into it one object at a time:
| Call | Answers |
|---|---|
GET /api/theme-files?themeId= |
[{ path, size, lastModified }] |
GET /api/theme-files/download?themeId=&path= |
The raw bytes — not a JSON envelope |
POST /api/theme-files/upload?themeId=&path= |
Uploads one file part to that relative path |
Note the two layers this creates. The images, scripts and stylesheets resources keep a theme's
assets as folders and files, with upload, delete and folder operations, and scripts and
stylesheets also let you read and rewrite a text file's content (GET …/item, POST …/save). The
/css, /js and /images addresses, however, read the theme store — so a theme's stylesheet reaches
a visitor through the theme-files mirror, not through the folder rows.
Working from a directory
The CLI keeps a theme on disk in the same shape as the store, and moves it in both directions:
snolla pull --themes --site <site-id> --out ./
snolla push
pull --themes writes one directory per theme:
themes/<name>/
_theme.json the theme row, verbatim
layouts/<name>.liquid one file per layout, under the layout's own name
css/ js/ images/ the theme's static files, at their relative paths
push walks the same tree: _theme.json goes back through themes/save, each layout through
layouts/upload, and every other file — skipping layouts/ and _theme.json — through
theme-files/upload. Pushed once, pushed twice, the result is the same. Theme names that collide
after slugging are suffixed on the way out, with a warning, so a pull never overwrites a directory.
Nothing in that tree is generated between the two directions, which means a theme can be edited in an editor, reviewed as a diff, and pushed — or pulled, changed, and pushed back.
Checking a theme
snolla lint runs one rule-set over the theme, the templates and the fixtures, and reports each
finding as file:line:col severity Rule message, exiting non-zero when there is an error:
snolla lint --dir ./
| Class | What it holds |
|---|---|
conformance |
A field a template or a fixture uses that the template definition does not declare |
liquid-correctness |
Unknown tags and filters, unclosed tags, source that does not parse |
theme-integrity |
A referenced partial or layout that does not exist |
cross-artifact |
A fixture without a template, a template without a view |
The same engine answers the editor: @snolla/theme-check is imported by the CLI and by the language
server, so a finding in an editor and a finding in CI are the same finding.
Related
- Templates and fields — where an image field is declared, and what a gallery field looks like in a template.
- Building a template — the record an image belongs to.
- Forms and submissions — the AJAX layout a submission can render.
- CLI reference —
pull,push,lint, and the asset commands that verify a site's stored objects.