First content
A page is three things: a template that declares its fields, a record that fills them in, and a read that returns the result. Nothing else has to exist first — no theme, no navigation, no configuration.
On your machine, from fixtures
A scaffolded project already has one of each, and snolla dev renders them from disk.
fixtures/templates/landing.template.json declares the template:
{
"kind": "pageTemplate",
"alias": "landing",
"name": "Landing Page",
"fields": [
{ "name": "headline", "fieldTemplate": "textEditorTemplate", "value": "Welcome" },
{ "name": "body", "fieldTemplate": "markItUpHtmlEditorTemplate", "value": "<p>Edit the page</p>" }
]
}
fixtures/pages/home.json fills it in:
{
"id": "page-home",
"path": "/",
"title": "Home",
"published": true,
"template": "landing",
"content": {
"headline": "Welcome to your new snolla site",
"body": "<p>This page renders from <code>fixtures/pages/home.json</code>.</p>"
}
}
views/landing.liquid renders it — the file name is the template's alias, and each field is
reachable as item.<field name>:
{% layout 'layouts/theme' %}
{% block content %}
<h1>{{ item.headline }}</h1>
{{ item.body }}
{% endblock %}
Change headline in the page file and the running site shows the new value; add a field to the
template and to the page, print {{ item.my_field }} (a name with a space or a leading digit needs
brackets, {{ item['3dview'] }}), and the site shows it. That loop — template, record, view — is
the whole content model.
On a site with a database
The same three pieces, written through the admin API, with the same credential as
Access and credentials: $ADMIN_API and the cookie the login call left in
cookies.txt. The identifier <site-id> is the siteId of snolla.config.json from
Create a site. A template first:
curl -X POST "$ADMIN_API/api/page-templates/save" \
-H 'content-type: application/json' \
-b cookies.txt \
-d '{
"siteId": "<site-id>",
"name": "Landing Page",
"alias": "landing",
"content": "[{\"name\":\"headline\",\"fieldTemplate\":\"textEditorTemplate\",\"value\":\"Welcome\"},{\"name\":\"body\",\"fieldTemplate\":\"markItUpHtmlEditorTemplate\",\"value\":\"<p>Edit the page</p>\"}]"
}'
alias is what the engine looks up as the Liquid entry, and content is the field list
stringified — the same array the fixture file carries in fields, as one JSON string.
Then the page, which needs the template's identifier from the response above:
curl -X POST "$ADMIN_API/api/pages/save" \
-H 'content-type: application/json' \
-b cookies.txt \
-d '{
"pageId": "<its-own-uuid>",
"siteId": "<site-id>",
"title": "Home",
"path": "/",
"templateId": "<template-id-from-above>",
"published": true,
"fields": [
{ "name": "headline", "value": "Welcome to your new snolla site" },
{ "name": "body", "value": "<p>Written through the admin API.</p>" }
]
}'
Every field name must be declared by the template: a write with an undeclared field is refused with
400 and the field named in the message, instead of storing content no view can render. Omitting
published writes false — a page written but not published is not content the site serves.
The two formats differ on purpose, and the difference is what each side knows about a site. The
fixture names its template by alias and keeps values in one content object, because on disk
there is one template tree; the API takes templateId and a fields array of {name, value},
because a database holds many templates and field order must survive.
Read it back
The public surface answers one path with the template it resolved and the field values. Fields are flattened onto the object — one key per declared field, next to the page's own keys:
CONTENT_API=http://localhost:5000
curl "$CONTENT_API/pages/viewModel?path=/"
{
"id": "…",
"path": "/",
"title": "Home",
"published": true,
"type": "page",
"template": { "id": "…", "alias": "landing", "name": "Landing Page" },
"headline": "Welcome to your new snolla site",
"body": "<p>Written through the admin API.</p>"
}
That is what a front end consumes — and what the generated client types for you, once the template exists:
const page = await client.getPageViewModel('/');
console.log(page.template.alias); // 'landing' — for display; compare `template.id` when branching
console.log(page.headline); // the field, typed by this template
Listing pages under a directory, with filters, sorting and paging, is the same public surface with
the selection language — GET /pages?path=/news&hitsPerPage=24, answered as
{ pages, limit, offset, total, facets? }. The typed client reaches it as client.pages.queryPages,
and Generate a typed client lists the keys: filter,
sort, page, hitsPerPage, facets.
Where to go next
- Generate a typed client — turn the templates you now have into typed models and a typed client.
- Admin API reference — the full set of resources a template and a page can carry (sitemap flags, layouts, parts, review settings).