Skip to content

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:

PatternPages can live…
**/*.mdanywhere — the collection root or any depth of folder
**/*.mdxanywhere, and new pages are created as .mdx
*/*.mdonly one folder down (e.g. recipes/dinner/) — never at the root
*.mdonly 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.