Skip to content

Change the content model

The content model, src/content/model.ts, lists every field your pages read. Keystatic’s editor and Sanity’s Studio are generated from it, so a change there reaches both.

  1. Add the field to the right part of src/content/model.ts, e.g. a subtitle on blog posts:

    subtitle: z.string().optional().meta({ title: 'Subtitle' }),
  2. Use it in the page or component that shows it.

  3. Keystatic picks it up at once (the dev server restarts by itself).

  4. Using Sanity: run pnpm cms sanity schema and redeploy the Studio (cd studio && npm run deploy). Using EmDash: run npm run emdash:schema against your site (see EmDash).

Optional fields (.optional()) are safest: existing content stays valid. Rules such as .regex(), .min() and .max() are checked in the editors as well as in the build.

Home and landing pages are lists of sections. A new section type needs:

  1. its fields in the sections list of the model,
  2. a component in src/components/sections/,
  3. one line in src/components/Sections.astro.

Then, with Sanity, regenerate the schema and redeploy the Studio as above; with EmDash, run npm run emdash:schema.