{"record":{"id":"d8c96c6f12f153e2","repo":"sveltejs/kit","slug":"multiple-layout-component-files-found-in-routes","errorCode":null,"errorMessage":"Multiple layout component files found in ${routes_base}${route.id} : ${path.basename(existing_file)} and ${file.name}","messagePattern":"Multiple layout component files found in (.+?)(.+?) : (.+?) and (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/sync/create_manifest_data/index.js","lineNumber":313,"sourceCode":"\t\t\t\tfunction duplicate_files_error(type, existing_file) {\n\t\t\t\t\treturn new Error(\n\t\t\t\t\t\t`Multiple ${type} files found in ${routes_base}${route.id} : ${path.basename(\n\t\t\t\t\t\t\texisting_file\n\t\t\t\t\t\t)} and ${file.name}`\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (item.kind === 'component') {\n\t\t\t\t\tif (item.is_error) {\n\t\t\t\t\t\troute.error = {\n\t\t\t\t\t\t\tdepth,\n\t\t\t\t\t\t\tcomponent: project_relative\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if (item.is_layout) {\n\t\t\t\t\t\tif (!route.layout) {\n\t\t\t\t\t\t\troute.layout = { depth, child_pages: [] };\n\t\t\t\t\t\t} else if (route.layout.component) {\n\t\t\t\t\t\t\tthrow duplicate_files_error('layout component', route.layout.component);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\troute.layout.component = project_relative;\n\t\t\t\t\t\tif (item.uses_layout !== undefined) route.layout.parent_id = item.uses_layout;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (!route.leaf) {\n\t\t\t\t\t\t\troute.leaf = { depth };\n\t\t\t\t\t\t} else if (route.leaf.component) {\n\t\t\t\t\t\t\tthrow duplicate_files_error('page component', route.leaf.component);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\troute.leaf.component = project_relative;\n\t\t\t\t\t\tif (item.uses_layout !== undefined) route.leaf.parent_id = item.uses_layout;\n\t\t\t\t\t}\n\t\t\t\t} else if (item.is_layout) {\n\t\t\t\t\tif (!route.layout) {\n\t\t\t\t\t\troute.layout = { depth, child_pages: [] };\n\t\t\t\t\t} else if (route.layout[item.kind]) {","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/sync/create_manifest_data/index.js#L295-L331","documentation":"SvelteKit's route scanner requires exactly one layout component per route directory. When create_manifest_data's walk finds a second +layout.svelte in the same route directory, it throws an error naming both conflicting files via duplicate_files_error('layout component', ...).","triggerScenarios":"Two layout component files resolve to the same route id, e.g. both `+layout.svelte` and `+layout@foo.svelte` (a named layout usage) present in one directory, or case-variant duplicates on case-insensitive filesystems.","commonSituations":"Copying a named-layout example (+layout@main.svelte) into a folder that already has +layout.svelte; merging branches that each added a layout; file renames that left an old layout behind.","solutions":["Remove one of the conflicting layout component files in that route directory","If you intended a named layout, ensure it lives in a different directory or rename so only one layout component remains per route","Re-run `vite dev`/`svelte-kit sync` after cleanup to confirm the manifest builds"],"exampleFix":"# before\nsrc/routes/+layout.svelte\nsrc/routes/+layout@alt.svelte\n\n# after (keep one)\nsrc/routes/+layout.svelte","handlingStrategy":"validation","validationCode":"import { readdirSync } from 'node:fs';\nconst files = readdirSync('src/routes', { recursive: true });\nfor (const dir of new Set(files.map((f) => f.split('/').slice(0, -1).join('/')))) {\n  const layouts = files.filter((f) => f.startsWith(dir) && /\\+layout(@[^/]+)?\\.svelte$/.test(f));\n  if (layouts.length > 1) throw new Error(`duplicate layout component in ${dir}: ${layouts}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One +layout.svelte per route directory","Search routes with a glob before adding layouts (e.g. `**/+layout*.svelte`)","Add a lint script that fails on duplicate route files"],"tags":["routing","config","duplicate-files"],"backgroundTag":"duplicate-route-file","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}