withastro/astro · warning
Auto-generating collections for folders in "src/content/" t
Error message
Auto-generating collections for folders in "src/content/" that are not defined as collections.
This is deprecated, so you should define these collections yourself in "src/content.config.ts".
The following collections have been auto-generated: ${orphanedCollections.map((name) => colors.green(name)).join(', ')}
What it means
Content collections must be declared explicitly in src/content.config.ts. When folders exist under src/content/ with no matching collection definition, Astro auto-generates glob-loader collections for them (tagged with an internal legacy flag) and prints this deprecation warning listing the auto-generated names. The implicit folder-based convention is going away, so each folder should become an explicit collection.
Source
Thrown at packages/astro/src/content/utils.ts:613
continue;
}
if (entry.isDirectory() && !(collectionName in collections)) {
orphanedCollections.push(collectionName);
const base = new URL(`${collectionName}/`, contentDir);
collections[collectionName] = {
type: CONTENT_LAYER_TYPE,
loader: glob({
base,
pattern: contentPattern,
[secretLegacyFlag]: true,
}) as any,
};
}
}
if (orphanedCollections.length > 0) {
console.warn(
`
Auto-generating collections for folders in "src/content/" that are not defined as collections.
This is deprecated, so you should define these collections yourself in "src/content.config.ts".
The following collections have been auto-generated: ${orphanedCollections
.map((name) => colors.green(name))
.join(', ')}\n`,
);
}
}
return { ...config, collections };
}
export async function reloadContentConfigObserver({
observer = globalContentConfigObserver,
...loadContentConfigOpts
}: {
fs: typeof fsMod;View on GitHub (pinned to 52e6c34790)
Solutions
- Open src/content.config.ts and define every collection named in the warning using glob({ base: './src/content/<name>', pattern: '**/*' }) plus an optional zod schema
- Restart the dev server so the content layer re-syncs against the explicit definitions
- Delete the folder if it was not meant to be a collection
Example fix
// before: src/content/blog exists but src/content.config.ts is empty/missing it
// after: src/content.config.ts
import { defineCollection, z } from 'astro:content';
import { glob } from 'astro/loaders';
const blog = defineCollection({
loader: glob({ pattern: '**/*.md', base: './src/content/blog' }),
schema: z.object({ title: z.string(), pubDate: z.date() }),
});
export const collections = { blog }; Defensive patterns
Strategy: validation
Validate before calling
// fail when a folder under src/content has no matching collection definition
import { readdirSync, statSync } from 'node:fs';
import { collections } from './src/content.config.ts'; // via tsx/jiti
const defined = new Set(Object.keys(collections ?? {}));
for (const name of readdirSync('src/content')) {
if (statSync(`src/content/${name}`).isDirectory() && !defined.has(name)) {
throw new Error(`src/content/${name} is not a defined collection — add it to content.config.ts`);
}
} Prevention
- Treat content.config.ts as the single source of truth: create the collection entry in the same commit as the folder
- Run `astro sync` in CI — explicit definitions remove the auto-generation path entirely
- Watch deprecation warnings on major upgrades and migrate conventions promptly
When it happens
Trigger: Any directory directly under src/content/ that contains content files but has no entry in the `collections` export of src/content.config.ts (or no content config at all) gets auto-generated and named in the warning.
Common situations: Upgrading a project from older Astro versions where folders implied collections; adding a new content folder without updating the config; copying example projects from outdated tutorials.
Related errors
- FileGlobNotSupported
- [astro] ${names} ${isPlural ? 'are' : 'is'} deprecated. Move
- Using deprecated `session.driver` string signature. Learn ho
- The adapter ${adapterName} has deprecated its support for "$
- ${names} on `mdx({...})` ${isPlural ? 'are' : 'is'} deprecat
AI-assisted analysis of withastro/astro@52e6c34790 (2026-08-18).
Data as JSON: /api/errors/9d2c7fb576001105.
Report an issue: GitHub.