Skip to main content
Every Cactal website gets a generated @website SDK based on its current CMS schema. Page code uses that SDK to define routes, declare server-side CMS queries, and render typed results.

Page definition

A page directly default-exports definePage({ ... }):
pages/post
The default export, definePage call, top-level object, and route literal must be direct and inline. Top-level object spreads, computed properties, indirect exports, variables used as routes, and route template literals fail static extraction. See Configure routes and redirects for the complete route grammar and matching behavior. See Configure SEO metadata for metadata fields and templates.

Generated CMS query builder

The cms object has one property per collection slug in the website’s CMS schema. Each collection supports get and list:
Collection slugs, field keys, option choices, required fields, reference targets, and result types are inferred from the schema. A nonexistent collection, field, or option value is a type error and also fails the framework quality gate. A page can declare at most 20 queries. Query names must be safe JavaScript identifiers with at most 64 characters, and cannot be __proto__, constructor, or prototype.

Get one item

Use exactly one of slug or id:
If the parameter is absent or no published item matches, Cactal serves the site’s custom not_found page with HTTP 404, exactly as it does for an unmatched route. Sites without a not_found file get the standard platform 404. Use a list query when an empty result is valid page content.

List items

list returns published items in manual CMS order by default:
pages/blog

List inputs

Do not use cursor and page together. The list result includes both nextCursor and nextPage; use the value matching your pagination style.

Filters

A filter can address at most 20 fields and contain at most 50 field/operator clauses. Unlike the REST item-list endpoint, the page query builder filters schema fields only, not item metadata such as createdAt, publishedAt, or publishAt. Use slug to filter a reference from a dynamic route without first looking up the referenced item id:
Reference slug traversal is limited to one level. It is applied by the CMS before limit, cursor, or page, so pagination describes the filtered set.

Search and sort

Search accepts a string or request parameter:
Restrict search to selected text, markdown, link, email, or color fields with an object:
Sort supports one schema field. Text, markdown, references, assets, galleries, files, and multiple-choice option fields are not sortable through page queries. Sort fields and directions must be static; they cannot be request-parameter placeholders.

Bind request parameters

The queries function receives a placeholder builder named param:
  • param.path(name) is type-checked against :name segments in the page route.
  • param.query(name) reads one query-string key.
  • Values are coerced for their destination. Numeric pagination and number filters require numbers; boolean filters accept true or false.
  • Repeated query-string values are accepted only where an in or nin filter expects multiple values.
Missing parameter behavior depends on its use: Path and query parameters are source-specific. A missing path parameter never falls back to a query parameter with the same name.

Render results

The render function receives:

Item result

get returns:
The actual fields type is generated from the collection. Optional values include null; gallery and multi-value fields use arrays. Image and file fields include their ready CDN URL and asset metadata. At depth: 0, references are item ids. At greater depths, references become nested items with the same { id, slug, fields, meta } shape. The page query maximum is 2, even though direct CMS API reads support depth 3.

List result

list returns:

Published content and schema changes

Published sites and draft previews both query published CMS items. Draft, scheduled, unpublished, and deleted items do not appear in page results. A scheduled item begins appearing after Cactal promotes it and records publishedAt. The published website guards its schema. A collection or field change that would break published page queries is rejected. Update page source, publish the compatible code, then change the schema. Collection-slug and field-key renames use dedicated CMS operations that migrate references safely.

Sitemap discovery

A dynamic route can be enumerated in the generated sitemap when it has exactly one route parameter and exactly one get query whose slug or id is bound to that parameter:
See Configure SEO metadata for the complete crawler behavior.

Troubleshooting

Next steps