Content modelingPage types

Defining a page type

A page type is a page component with zones: the places where editors add sections. This page walks through the Lorem Co. starter's Home and Page types, and what a page type learns about its place in the site.

View as Markdown

The schema

A page type starts with smoodly.schema.page(): a name, a title, and a zones map that gives each zone a policy. The schema is the same file in every framework; in an Astro project it lives under src/components/pages/.

components/pages/Home.schema.ts
import { smoodly, z } from "smoodly";
import { heroSchema } from "../sections/Hero.schema";
// …
export const homeSchema = smoodly.schema.page({
  name: "home",
  title: "Home",
  slug: "home",
  zones: {
    hero: z.locked(heroSchema),
    body: z.freeform({ sections: [imageTextSchema, pointsSchema, favouriteArticlesSchema, peopleSchema, quoteSchema], custom: true }),
  },
  seo: true,
});
nameWhat a page record stores as its type. Keep it stable once pages exist.
titleWhat editors see in the Page type column and when they create a page.
slugMakes the page type fixed: one page, at this URL. Leave it out and editors create as many as they like. See below.
zonesOne entry per zone, each with a policy from z. Zones and freedom covers the three.
seo`true` gives the page an SEO & Social tab: title, description, social image and a switch to hide it from search engines.
fieldsThe page type's own fields, edited on the page's Settings tab. See below.

The view

The view is src/page-types/home.astro, named after the schema. It receives page, zones and head. Render each zone with <Zone> wherever it belongs, among your own markup:

src/page-types/home.astro
---
import { Zone } from "smoodly/astro/components";
// …
const { page, zones, head } = Astro.props;
---
<Layout head={head} locale={page.locale} locales={page.locales}>
  <Zone of={zones.hero} />
  <Zone of={zones.body} />
</Layout>

Layout is the starter's own component: the document, the site header and footer. Anything you render around the zones shows in the canvas but cannot be selected, so editors cannot move or remove it. head is what Head writes into the document head: the title, the canonical link and the rest.

Register the schema in the pages list of src/smoodly/config.ts; the view is the file, with nothing else to list:

src/smoodly/config.ts
export const config = defineConfig({
  registry: {
    sections,
    // …
    pages: [homeSchema, articlesSchema, pageSchema, newsSchema],
  },
  // …
});

Fixed and open

A page type with a slug is fixed: it owns exactly one page, at that URL, in every language. Smoodly creates the page the first time the admin loads, so a fresh site has a home page before anyone signs in. Editors can edit it but never create another, rename it, move it or delete it. The slug home is special: homePageSlug in defineConfig() names it, and that page is served at /.

A fixed slug can differ per language. The starter's Articles index sits at /posts in English and /artikkelit in Finnish:

components/pages/Articles.schema.ts
export const articlesSchema = smoodly.schema.page({
  name: "articlesIndex",
  title: "Articles",
  slug: { en: "posts", fi: "artikkelit" },
  zones: {
    hero: z.locked(pageHeroSchema),
  },
  seo: true,
});

A page type without a slug is open: editors create as many pages of it as they like, anywhere the page tree allows. When they click + New page, the admin asks which open page type to use. With one open type, as in the starter, it does not ask.

Lorem Co. has three fixed types, Home, Articles and News, and one open type, Page. A fixed page is live as soon as its code is deployed, with empty zones until an editor fills them. Its row appears in Pages the next time someone opens the admin. Article and News post are entry pages, which render one entry each.

The page prop

page tells the view where the page sits, so breadcrumbs and sub-navigation need no query:

page.title, page.localeThe page's title and the language it is rendered in.
page.path, page.urlThe page's URL within the site, and the same address through your framework's locale routing. On a single-language site they are equal.
page.ancestorsLinks to the pages above it, root first.
page.childrenLinks to the pages below it.
page.localesOne key per language: the page's address there, or null where it does not exist or is unpublished. What a language switcher links to.
page.fieldsThe page type's own fields, typed from the schema.

Each link carries title, path, url, hasPage and fields. A path in the page tree, which groups pages without being one, has hasPage false. The starter's Page type uses both lists:

src/page-types/page.astro
---
// …
const shown = page.children.filter((c) => c.hasPage && c.fields.showInNavigation === true);
---
<Layout head={head} locale={page.locale} locales={page.locales}>
  {page.ancestors.length > 0 && (
    <nav class="container breadcrumb" aria-label="Breadcrumb">
      {page.ancestors.map((a) => <span>{a.hasPage ? <a href={a.url}>{a.title}</a> : a.title} / </span>)}
      {page.title}
    </nav>
  )}
  {shown.length > 0 && (
    <nav class="container subnav" aria-label="Pages in this section">
      {shown.map((c) => <a href={c.url}>{c.title}</a>)}
    </nav>
  )}
  <Zone of={zones.hero} />
  <Zone of={zones.body} />
</Layout>

Page fields

A page type can declare fields of its own, for values that belong to the page rather than to a section. The starter's Page type has one:

components/pages/Page.schema.ts
export const pageSchema = smoodly.schema.page({
  name: "page",
  title: "Page",
  zones: {
    hero: z.locked(pageHeroSchema),
    body: z.freeform({ sections: [imageTextSchema, pointsSchema, favouriteArticlesSchema, peopleSchema, quoteSchema], custom: true }),
  },
  seo: true,
  fields: { showInNavigation: f.boolean().default(true) },
});

Editors find it on the page's Settings tab, next to the title and slug. The view reads it as page.fields.showInNavigation, and every link in ancestors and children carries the linked page's fields, which is how the sub-navigation above filters without a query.

Page fields are a settings form, not content: text, link, date, number, boolean, the choice fields, tags, media and objects. Refs, lists and richtext are not allowed, and .localized() is not needed because page fields are already stored per language.

Next, Zones and freedom explains the three policies a zone can have.

Edit this page on GitHubLast updated 6 Oct 2026