{"record":{"id":"9d2c7fb576001105","repo":"withastro/astro","slug":"auto-generating-collections-for-folders-in-src-c","errorCode":null,"errorMessage":"\nAuto-generating collections for folders in \"src/content/\" that are not defined as collections.\nThis is deprecated, so you should define these collections yourself in \"src/content.config.ts\".\nThe following collections have been auto-generated: ${orphanedCollections.map((name) => colors.green(name)).join(', ')}\n","messagePattern":"\nAuto-generating collections for folders in \"src/content/\" that are not defined as collections\\.\nThis is deprecated, so you should define these collections yourself in \"src/content\\.config\\.ts\"\\.\nThe following collections have been auto-generated: (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro/src/content/utils.ts","lineNumber":613,"sourceCode":"\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (entry.isDirectory() && !(collectionName in collections)) {\n\t\t\t\torphanedCollections.push(collectionName);\n\t\t\t\tconst base = new URL(`${collectionName}/`, contentDir);\n\t\t\t\tcollections[collectionName] = {\n\t\t\t\t\ttype: CONTENT_LAYER_TYPE,\n\t\t\t\t\tloader: glob({\n\t\t\t\t\t\tbase,\n\t\t\t\t\t\tpattern: contentPattern,\n\t\t\t\t\t\t[secretLegacyFlag]: true,\n\t\t\t\t\t}) as any,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif (orphanedCollections.length > 0) {\n\t\t\tconsole.warn(\n\t\t\t\t`\nAuto-generating collections for folders in \"src/content/\" that are not defined as collections.\nThis is deprecated, so you should define these collections yourself in \"src/content.config.ts\".\nThe following collections have been auto-generated: ${orphanedCollections\n\t\t\t\t\t.map((name) => colors.green(name))\n\t\t\t\t\t.join(', ')}\\n`,\n\t\t\t);\n\t\t}\n\t}\n\n\treturn { ...config, collections };\n}\n\nexport async function reloadContentConfigObserver({\n\tobserver = globalContentConfigObserver,\n\t...loadContentConfigOpts\n}: {\n\tfs: typeof fsMod;","sourceCodeStart":595,"sourceCodeEnd":631,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/content/utils.ts#L595-L631","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before: src/content/blog exists but src/content.config.ts is empty/missing it\n\n// after: src/content.config.ts\nimport { defineCollection, z } from 'astro:content';\nimport { glob } from 'astro/loaders';\n\nconst blog = defineCollection({\n  loader: glob({ pattern: '**/*.md', base: './src/content/blog' }),\n  schema: z.object({ title: z.string(), pubDate: z.date() }),\n});\n\nexport const collections = { blog };","handlingStrategy":"validation","validationCode":"// fail when a folder under src/content has no matching collection definition\nimport { readdirSync, statSync } from 'node:fs';\nimport { collections } from './src/content.config.ts'; // via tsx/jiti\n\nconst defined = new Set(Object.keys(collections ?? {}));\nfor (const name of readdirSync('src/content')) {\n  if (statSync(`src/content/${name}`).isDirectory() && !defined.has(name)) {\n    throw new Error(`src/content/${name} is not a defined collection — add it to content.config.ts`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["content-collections","deprecation","config"],"backgroundTag":"deprecated-convention-requires-explicit-config","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}