CollectionsDefining a collection

Defining a collection

A collection is a content type with a fixed shape and many entries: posts, people, products. You declare its fields once; editors get a list, a form and publishing for it.

View as Markdown

The schema

smoodly.collection() takes a name, a title and the fields of one entry:

smoodly/collections.ts
import { f, smoodly } from "smoodly";
// …
export const people = smoodly.collection({
  name: "people",
  title: "People",
  titleField: "name",
  order: "manual",
  fields: {
    name: f.text(),
    role: f.text().localized(),
  },
});
nameWhat references and queries use. Keep it stable once entries exist. global, asset and media are reserved.
titleThe label in the admin's navigation and list.
titleFieldThe field whose value names an entry in lists and pickers. Without one, or while it is empty, an entry reads Untitled.
fieldsAny builders. A field named slug gives entries a URL part; .localized() gives a field a value per language.
pathServes each entry at its own URL under this segment. See Entry pages.
orderHow the list and queries sort. See Ordering.
admin.showInNavtrue gives the collection its own item in the admin's main navigation, after Pages, instead of a line in the Collections menu. Default false.
seoAdds the SEO & Social panel to the entry form; `{ description, image }` names the fields that fill an empty description and social image. See SEO.

Register the export in the collections list of smoodly/collections.ts, which the config registers. Every collection stores its entries in the same tables, so the admin lists a new one at once. Smoodly's service indexes the new collection's lists itself: there is nothing to migrate.

Entries in the admin

The Collections item in the admin's top bar opens a menu of every collection. A collection editors open all day can sit on the bar itself: add admin: { showInNav: true } to its schema and it appears after Pages under its title, and leaves the menu. A collection's list shows its entries with their title, status and when they changed, 20 to a page; Previous and Next under the rows move through a longer list, and Per page shows 100 or 500 instead, a choice the browser remembers. The box above the rows filters by the collection's titleField: it finds the entries whose title holds the text, in any language, and searches the whole collection, not the page on screen. A collection without a titleField has no filter. While a filter is on, a hand-ordered list does not drag. + New entry creates an empty draft in the selected language and opens the form at once. The form autosaves, and carries the same Publish control as a page, so an entry is published per language like a page. History and Discard changes work the same way.

An entry cannot be deleted while a page, a section or another entry references it. The message says how many, and the media library shows the same for assets.

Shared and localized

A field's value is shared across languages unless it chains .localized(). In the starter's people, a person's name is the same everywhere and the role is translated. The form marks shared fields with a globe-off icon on a multilingual site, and the slug is always per language. Localized fields has the rules.

Where entries appear

Three ways, which the next pages cover:

  • Referenced from a section or another entry with f.ref() or f.refList(): the starter's People section picks team members by hand. See Reference and tags.
  • At their own URL, when the collection has a path and an entry page.
  • Queried from your code with q(), for an index grid or a related list. See Queries.

Next, Entry pages.

Edit this page on GitHubLast updated 14 Nov 2026