Content Collections, Explained
A practical tour of how Dogbro uses typed content collections to manage blog posts, case studies, and service pages.
Modern AI content platforms need structured, queryable data. At Dogbro, we use content collections to manage everything from blog posts to service pages.
Define the collection
A collection pairs a loader (where the files live) with a schema (what their frontmatter must contain):
import { defineCollection, z } from 'astro:content';
import { glob } from 'astro/loaders';
const blog = defineCollection({
loader: glob({ base: './src/content/blog', pattern: '**/*.{md,mdx}' }),
schema: z.object({
title: z.string(),
pubDate: z.coerce.date(),
tags: z.array(z.string()).default([]),
}),
});
export const collections = { blog };
Because the schema is Zod, a typo in your frontmatter fails the build instead of shipping a broken page.
Why this matters for AI content
When you generate hundreds of articles, consistency is everything. Typed frontmatter ensures every post has the right title, date, and tags — making automation reliable and SEO-friendly.
MDX lets you drop components into prose when you need interactive elements like AI preview demos, calculators, or comparison tables. For everyday writing, plain Markdown is lighter and just as well supported.