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.
Add a field
Section titled “Add a field”-
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' }), -
Use it in the page or component that shows it.
-
Keystatic picks it up at once (the dev server restarts by itself).
-
Using Sanity: run
pnpm cms sanity schemaand redeploy the Studio (cd studio && npm run deploy). Using EmDash: runnpm run emdash:schemaagainst 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.
Add a section type
Section titled “Add a section type”Home and landing pages are lists of sections. A new section type needs:
- its fields in the
sectionslist of the model, - a component in
src/components/sections/, - 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.