Astro · Content collections

Setting up a collection

Collections are pure Astro — Orbit just reads them, so if your site already has content collections there’s nothing to add. To create one, define it in src/content.config.ts (Astro 5+; src/content/config.ts on Astro 2–4). The Zod schema becomes the editor form — see The editor form.

import { defineCollection, z } from "astro:content";
import { glob } from "astro/loaders";

const blog = defineCollection({
  loader: glob({ pattern: "**/*.{md,mdx}", base: "./src/content/blog" }),
  schema: ({ image }) =>
    z.object({
      title: z.string(),
      date: z.date(),
      draft: z.boolean().default(false),
      cover: image().optional(),        // gives editors a picker
    }),
});

export const collections = { blog };

Put the Markdown/MDX entries under src/content/blog/ — in sub-folders if you like (blog/2025/spring/planting.md). The glob pattern decides where entries may live, and Orbit follows it exactly:

Pattern Pages can live…
**/*.md anywhere — the collection root or any depth of folder
**/*.mdx anywhere, and new pages are created as .mdx
*/*.md only one folder down (e.g. recipes/dinner/) — never at the root
*.md only at the root; files in sub-folders aren’t part of the collection

To give editors a new folder to add pages to, create it with at least one entry and commit it — or set newFolders: true on the collection if your routes handle nested IDs. Full reference: Astro’s Content collections guide.