Skip to content

Content Collections

Astro Content Collections load local content and validate frontmatter with schemas. In modern Astro projects, src/content.config.ts defines collections through the Content Layer API.

This file defines the collections, loaders, and schema validation used by the theme. For Verdict Law, it should define collections for attorneys, blog articles, and practice areas.

Invalid frontmatter can fail the build. This is useful because broken content is caught before deployment.

Common validation failures include:

  • Missing required fields.
  • Wrong date format.
  • Incorrect image value.
  • Invalid reference slug.
  • Boolean fields written as strings.

Collection entries are queried by pages such as src/pages/attorneys/[slug].astro, src/pages/practice-areas/[slug].astro, and src/pages/insights/[slug].astro. The slug is usually derived from the entry ID or file path, but the exact behavior depends on the loader.

Astro pages can query entries with APIs from astro:content.

Example only:

import { getCollection } from 'astro:content';
const attorneys = await getCollection('attorneys');

Confirm the real collection names in src/content.config.ts.