Astro glossaryContent collections are Astro's way of managing sets of content, such as posts or docs, with a loader, a schema, and type-safe queries.
A content collection is a set of entries with the same structure, such as blog posts, docs pages, or products, that Astro loads, validates, and lets you query. Each collection has a loader, which says where the entries come from, and an optional schema, which says what fields they must have.
How it works
- Loaders:
glob()reads Markdown, MDX, JSON, or YAML files from a folder,file()reads many entries from one file, and custom loaders pull from an API or a CMS. - Schemas are written with Zod. Astro checks every entry against them at build time and generates TypeScript types, so a missing field is a build error, not a broken page.
- Pages query with
getCollection()andgetEntry().
These build-time collections are saved when the site builds. For content that changes between builds, Astro has live collections.
Source: Astro docs: Content collections.