Skip to content
Best Practiceswarn by defaultrecommended presetastro-doctor/require-content-config

require-content-config

Add a content config when src/content contains entries.

Why

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.

Examples

Incorrect

Content entries exist without src/content.config.ts

text
src/
  content/
    blog/
      first-post.md

Correct

Define and export the collection

typescript
import { defineCollection, z } from 'astro:content'

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

export const collections = { blog }

Configuration

Project audits are configured in doctor.config.ts:

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

All rules