To disable the deprecated auto-generation of collections in Astro 5.9.0, you must explicitly define each collection in your src/content.config.ts file—even if you don't want to customize them. An empty export const collections = {} is not sufficient; Astro requires that every folder in src/content/ you want to use as a collection is declared, even if the declaration is empty.
For example, if you have src/content/blog/ and src/content/news/, your src/content.config.ts should look like:
import { defineCollection } from 'astro:content';
const blog = defineCollection({});
const news = defineCollection({});
export const collections = { blog, news };
This will stop Astro from auto-generating collections and remove the deprecation warning. Each key in the collections export must match a subfolder in src/content/ that you want to be a collection. If you add or remove folders, update this file accordingly.
Note:
- The knowledge sources confirm that "collections should always be defined in
src/content.config.ts," and that "these can just be empty declarations (e.g. const blog = defineCollection({}))" to be compatible with the new loading behavior. An empty object for collections will not suffice; you must declare each collection by name Breaking changes to legacy content and data collections.
- If you follow this approach and still see the warning, double-check that your collection names in
collections match the folder names exactly.
Let me know if you need help with a specific folder structure!
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: