Collection and field settings
Configure collection behavior and choose the controls editors use for individual fields.
On Astro, put collection options in a studio object alongside loader and schema in src/content.config.ts. To use the extra key with Astro’s TypeScript types, assign the options to a variable and pass that variable to defineCollection. Put field hints on the Zod field with .meta({ $content: { editor: { … } } }). The normal schema still supplies field types, descriptions, choices, defaults, and validation.
| Collection setting | Values and effect |
|---|---|
studio.slugs.editable | Set false to lock addresses throughout the collection. When omitted, Studio offers renaming for entries it can safely rename. An individual entry can also lock its own address. |
studio.bodyTemplate | String copied into the body of a newly created Markdown, MDX, or Markdoc entry. Without it, the body starts empty. Existing records keep their current body. |
studio.defaultLocale | Language code, for example en, for the first preview route when the default language has no URL prefix. Use it with localized editing tabs and a route array. |
studio.previewRoutes | List of local preview paths for the collection. Useful when many structured records appear on the same page. Studio can also infer a shared route from mapped records. A file-specific preview takes priority. |
Field setting under $content.editor | Values and effect |
|---|---|
input | Omit to use the schema-derived editor. Recognized hints include media (image picker), video (video input), icon (icon picker), date (date control), link (URL), internal-link (website route suggestions), and reference (choose a related entry). Match the field’s stored type to the control. |
hidden | Boolean, off by default. true leaves an optional field out of the form. Studio keeps required fields available so an editor can complete a valid record. |
collection | Target collection for a reference input. On Astro, use native reference('artists') to let Astro and Studio agree on the target and the stored entry ID. |
valueField | In an explicitly configured Nuxt Content reference, chooses the target field stored in the source record. Defaults to slug. Use path to store the target path. Astro’s native references follow Astro entry IDs. |
selector | For a reference array, tags (default) shows chosen entries as tags. select uses a selection control. An array-level hint takes precedence over an item-level hint. |
placeholder | Prompt for an empty reference-array selection. Defaults to Choose items. |
For example, link below offers existing pages to an editor, and artist stores the related artist’s Astro ID.
import { reference } from 'astro:content';
import { z } from 'astro/zod';
const fields = z.object({
link: z.string().meta({ $content: { editor: { input: 'internal-link' } } }),
artist: reference('artists'),
});