Skip to content
Editlet

Content model and field types

You describe your content in one file, cms/schema.json. The editor, the agent skill, the build and the generated types all read it, and every entry file must match it.

The schema file

{
  "contentDir": "cms/content",
  "git": { "baseBranch": "main" },
  "collections": {
    "post": {
      "label": "Post",
      "pluralLabel": "Posts",
      "url": "/posts/{slug}",
      "titleField": "title",
      "slugFrom": "title",
      "fields": {
        "title": { "type": "string", "label": "Title", "required": true },
        "body": { "type": "markdown", "label": "Body" }
      }
    },
    "home": {
      "label": "Home page",
      "singleton": true,
      "url": "/",
      "fields": { "title": { "type": "string", "label": "Title" } }
    }
  }
}
KeyMeaning
contentDirThe entries folder, relative to the project root
git.baseBranchThe branch the site deploys from; the editor opens pull requests into it
collections.<key>.labelThe name of one entry in the editor (Post); a singleton's only name
pluralLabelOptional: the name for many entries (Posts), for headings; not on a singleton. Without it the editor shows label
urlOptional: the path of the collection's page on your site; see Page URLs
singletontrue: the collection has one entry, index.md
titleFieldThe field that names an entry in lists
slugFromThe field the New dialog fills with the title; the slug is made from that title
groupsOptional tabs of the entry in the editor; see Field groups
fieldsA map of field key to field

An unknown key anywhere is an error. Collection and field keys start with a letter and hold only letters and digits.

Optional git keys name what the editor and the agent create:

KeyDefaultPlaceholders and rules
branchPrefixeditlet/Ends in /; must not clash with the base branch
commitMessage{Action} {target}{action} (create, update, delete, upload), {Action}, {collection}, {slug}, {target}
pullRequest.titleUpdate {branch}{branch}, {name} (without the prefix), {login}
pullRequest.labels["editlet"]At most 10; [] adds none
pullRequest.draftfalsetrue opens draft pull requests

Page URLs

url tells the editor where an entry is shown on your site. It is a path from the site's root:

  • /posts/{slug}: one page per entry. {slug} is replaced by the entry's slug (/posts/tires), the only placeholder.
  • /: a fixed path. Every entry of the collection is shown on that one page (sections of the homepage). A singleton's url is always a fixed path.
  • Keep your site's trailing / if it has one (/posts/{slug}/).
  • Leave url out for a collection that has no page of its own (authors, site settings).

With url, the editor shows an entry's page address and can open the entry's page on the site. Write the slug as {slug}, not as your framework's [slug] or :slug. A path must start with /, use plain ASCII (no spaces, ?, #, %, quotes, <, > or //), have at most 200 characters, and not be under /editlet/ or /__editlet. Routes that depend on a field (/2026/05/{slug}, /{category}/{slug}), language prefixes and base paths cannot be written yet; leave url out for those collections.

Field groups

A collection with many fields can split them into tabs in the editor. List the tabs in groups and put group on the fields that belong to a tab other than the first:

"post": {
  "label": "Post",
  "groups": { "content": { "label": "Content" }, "media": { "label": "Media" }, "settings": { "label": "Settings" } },
  "fields": {
    "title": { "type": "string", "label": "Title" },
    "cover": { "type": "image", "label": "Cover image", "group": "media" },
    "featured": { "type": "boolean", "label": "Show in the header", "group": "settings" }
  }
}

Fields without group are in the first tab. Only top-level fields take group, and it must name one of the collection's groups. A tab with changed fields shows an amber dot, one with errors a red dot; with one group the editor shows no tabs. Groups only change the editor: entry files and types stay the same.

Entry files

Each entry is one UTF-8 file, <contentDir>/<collection>/<slug>.md, with YAML frontmatter and a Markdown body:

---
title: Hello world
cover:
  src: hello-world/cover.webp
  alt: A lighthouse at dusk
draft: true
---

The body is the collection's markdown field.
  • Slug: lowercase letters and digits with single hyphens. The editor makes it from the title and drops other characters, so type it yourself for a non-Latin title.
  • Drafts: draft: true keeps the entry out of production builds. New entries from the editor start as drafts, copies made with ⋯ → Duplicate too. ⋯ → Set as draft (or Set as published) changes the flag; the editor saves it as any edit.
  • Files: besides entries, contentDir may hold only images and names starting with .. Anything else is an error.
  • YAML: the 1.2 core schema, so 2026-01-15 and yes stay strings. Saving in the editor drops comments.
  • Leave out empty optional fields instead of writing null or ''.

Field types

There are 14 types. Every field takes label (required), hint (help text) and required; a top-level field can also take group.

TypeOptionsIn the file
stringlist, defaulttitle: Hello; a list of strings with list: true
textrows (editor height), defaultA string, often a YAML block scalar
markdownnoneThe body. One per collection. Inside an object or block: a Markdown string
booleandefault, labels (true and false texts)featured: true
selectoptions ({ label, value }), multiple, defaultstatus: live; a list with multiple
numbermin, max, integer, step (editor only), defaultprice: 9.5
datetimedateOnly, defaultNow2026-01-15T09:00:00Z (Z, offset or local time); 2026-01-15 with dateOnly
jsonnoneAny YAML value
urlnonehttps://…, http://… or a path like /about
colordefaultaccent: '#1a2b3c', quoted because # starts a YAML comment
imagenone{ src, alt }, both required
referencecollections, multiple, min, maxauthor: author/jane; a list with multiple
objectfields, list, min, maxA mapping of its fields; a list of them with list: true. See Objects and blocks
blocksblocks (kind → { label, fields }), min, maxA list of mappings, each with block: <kind>. See Objects and blocks

New entries get each default (it must pass its own field) and defaultNow sets the current time. min and max count list items and need multiple or list. A required list needs at least one item.

References

A reference is collection/slug; a singleton is <collection>/index, such as home/index. A list cannot hold one reference twice. To build a tree (a survey with sections with questions), give each level its own collection and a multiple reference to the next.

Next.js reads a tree in one call, getEntry('survey', 'onboarding', { depth: 2 }); Astro needs one getEntries per level. Cycles are fine: reading stops at depth. In the editor, Rename… rewrites every reference and image path in one commit, and Delete can remove the references too, unless a required one would break.

Objects and blocks

Use them for parts that never live on their own. An object groups fields (an SEO group), or with list: true makes a list of groups (FAQ items). blocks is a list of items of different kinds:

"content": { "type": "blocks", "label": "Content", "blocks": {
  "hero": { "label": "Hero", "fields": { "title": { "type": "string", "label": "Title", "required": true } } },
  "prose": { "label": "Text", "fields": { "text": { "type": "markdown", "label": "Text" } } }
} }
content:
  - block: hero
    title: Spring sale
  - block: prose
    text: |
      Two weeks of **discounts**.

Any field type works inside, nesting included. block cannot be a field key in a block, and neither type takes a default. In code, if (b.block === 'hero') narrows an item to the hero's fields.

Images

src is relative to the entry file's folder: cms/content/post/hello-world.md uses hello-world/cover.webp. The file must exist inside contentDir and end in webp, png, jpg, jpeg, avif, gif or svg; URLs are errors. The editor uploads to <contentDir>/<collection>/<slug>/ in the same commit as the entry. Body images are not checked.

Validation

The editor checks before each save, the guard hook before a commit, and next build or astro build fail on an invalid entry. Run the check yourself:

node node_modules/editlet/skills/editlet/scripts/validate.mjs

It prints ✓ N entries valid, or one file: field.path — message line per issue and exit code 1.

MessageFix
Unknown fieldAdd the field to the schema, or remove the key
Referenced entry not found: author/janeCreate the entry, or fix the reference
This collection has no markdown field, but the entry has body contentRemove the body, or add a markdown field
Not an entry fileMove the file out of contentDir, or name it <collection>/<slug>.md

Generated types

In Next.js, withEditlet writes .editlet/content.d.ts when next dev or next build starts; pass its EntryMap to createReader. Astro types come from astro:content. To write the file by hand, run node node_modules/editlet/skills/editlet/scripts/types.mjs. Do not commit it.

Change the schema

Ask your agent, for example "rename cover to image in posts". The skill shows which entries change or lose values first, then updates the schema and the entries. The editor's Content model screen (?editlet=schema) shows the collections, fields and any problems.

For agents: this page as Markdown · llms.txt