Skip to contentView the source on GitHub

require-content-config

Add a content config when src/content contains entries.

Best Practiceswarning by default Project auditrecommended audit

astro-doctor/require-content-config

Why it matters

A content config defines collections and their schemas so Astro can type and validate content entries. Content files without defineCollection() lose those guarantees and allow invalid frontmatter to reach a build or production page.

See the difference

Incorrect

Content entries exist without src/content.config.ts

textIncorrect example
src/
  content/
    blog/
      first-post.md

Correct

Define and export the collection

typescriptCorrect example
import { defineCollection, z } from 'astro:content'

const blog = defineCollection({
  schema: z.object({
    title: z.string(),
  }),
})

export const collections = { blog }

Configure this check

Project audits are configured in doctor.config.ts:

typescriptdoctor.config.ts
export default {
  rules: {
    'astro-doctor/require-content-config': 'error',
  },
}

Use 'error', 'warn', or 'off'. The configuration guide covers presets and per-file overrides.

Keep exploring best practices

Browse every rule and project audit