Learning Astro Content Collections

Notes on how Astro 6 content collections work with the glob loader, Zod schemas, and the content store.

Astro 6 introduced a revamped content layer with defineCollection and pluggable loaders. The glob loader scans directories for Markdown/MDX files and validates frontmatter against a Zod schema.

Key takeaways so far:

  • Collections are defined in src/content.config.ts
  • The glob loader's base path determines where files live
  • Entry IDs are relative paths from the base (e.g., notes/my-note)
  • Schema defaults are applied at build time, not in the file
  • The content store (.astro/data-store.json) caches entries — delete it when debugging stale content