{"record":{"id":"48dc63f799d60531","repo":"withastro/astro","slug":"legacycontentconfigerror","errorCode":"LegacyContentConfigError","errorMessage":"Found legacy content config file in \"${filename}\". Please move this file to \"src/content.config.${ext}\" and ensure each collection has a loader defined.","messagePattern":"Found legacy content config file in \"(.+?)\"\\. Please move this file to \"src/content\\.config\\.(.+?)\" and ensure each collection has a loader defined\\.","errorType":"error_code","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/content/utils.ts","lineNumber":729,"sourceCode":"};\n\nexport function getContentPaths(\n\t{ srcDir, root }: Pick<AstroConfig, 'root' | 'srcDir'>,\n\tfs: typeof fsMod = fsMod,\n\tlegacyCollectionsBackwardsCompat = false,\n): ContentPaths {\n\tconst pkgBase = new URL('../../', import.meta.url);\n\tconst configStats = searchConfig(fs, srcDir);\n\n\tif (!configStats.exists) {\n\t\tconst legacyConfigStats = searchLegacyConfig(fs, srcDir);\n\t\tif (legacyConfigStats.exists) {\n\t\t\tif (!legacyCollectionsBackwardsCompat) {\n\t\t\t\tconst relativePath = path.relative(\n\t\t\t\t\tfileURLToPath(root),\n\t\t\t\t\tfileURLToPath(legacyConfigStats.url),\n\t\t\t\t);\n\t\t\t\tthrow new AstroError({\n\t\t\t\t\t...AstroErrorData.LegacyContentConfigError,\n\t\t\t\t\tmessage: AstroErrorData.LegacyContentConfigError.message(relativePath),\n\t\t\t\t});\n\t\t\t}\n\t\t\t// Use legacy config path when backwards compat is enabled\n\t\t\treturn getContentPathsWithConfig(root, srcDir, pkgBase, legacyConfigStats, fs);\n\t\t}\n\t}\n\n\tconst liveConfigStats = searchLiveConfig(fs, srcDir);\n\treturn {\n\t\troot: new URL('./', root),\n\t\tcontentDir: new URL('./content/', srcDir),\n\t\tassetsDir: new URL('./assets/', srcDir),\n\t\ttypesTemplate: new URL('templates/content/types.d.ts', pkgBase),\n\t\tvirtualModTemplate: new URL('templates/content/module.mjs', pkgBase),\n\t\tconfig: configStats,\n\t\tliveConfig: liveConfigStats,","sourceCodeStart":711,"sourceCodeEnd":747,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/content/utils.ts#L711-L747","documentation":"Thrown when Astro finds a legacy content config file (e.g. `src/content/config.ts`) but legacy collections backwards compatibility is not enabled. Astro 6 removed legacy content collections; config must now live at `src/content.config.*` with explicit loaders. The message tells you exactly where the legacy file is and where to move it.","triggerScenarios":"`getContentPaths` is called, `searchConfig` finds no modern `src/content.config.*`, then `searchLegacyConfig` finds a legacy `src/content/config.*`. Since `legacyCollectionsBackwardsCompat` is false (the default in Astro 6), the error is thrown.","commonSituations":"Upgrading from Astro 5 to Astro 6 without migrating the content config location. Cloning an older project that uses the `src/content/config.ts` path. CI pipeline fails immediately after an Astro version bump.","solutions":["Move `src/content/config.ts` to `src/content.config.ts` (keeping the same extension).","Add a `loader` to every collection definition (e.g. `glob({ pattern: '**/*.md', base: './src/content/blog' })`).","Remove the `type` field from collection definitions if present.","Optionally, temporarily enable backwards compat via `legacy: { collectionsBackwardsCompat: true }` in `astro.config` to ease migration, but plan to move off it."],"exampleFix":"// before — src/content/config.ts\nimport { defineCollection, z } from 'astro:content';\nconst blog = defineCollection({ type: 'content', schema: z.object({ title: z.string() }) });\n\n// after — src/content.config.ts\nimport { defineCollection, z, glob } from 'astro:content';\nconst blog = defineCollection({\n  loader: glob({ pattern: '**/*.md', base: './src/content/blog' }),\n  schema: z.object({ title: z.string() }),\n});","handlingStrategy":"validation","validationCode":"import { existsSync } from 'fs';\nif (existsSync('src/content/config.ts') || existsSync('src/content/config.js')) {\n  console.error('Legacy config found — move to src/content.config.ts');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["After upgrading to Astro 6, immediately move src/content/config.* to src/content.config.*.","Add loaders to every collection during migration.","Run the Astro upgrade guide checklist before deploying."],"tags":["content-collections","migration","astro-6","config"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}