{"record":{"id":"c69995caabbc7f87","repo":"withastro/astro","slug":"missingindexforinternationalizationerror","errorCode":"MissingIndexForInternationalizationError","errorMessage":"Could not find index page. A root index page is required in order to create a redirect to the index URL of the default locale. (`/${defaultLocale}`)","messagePattern":"Could not find index page\\. A root index page is required in order to create a redirect to the index URL of the default locale\\. \\(`/(.+?)`\\)","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/routing/create-manifest.ts","lineNumber":774,"sourceCode":"\t// Report route collisions\n\tfor (const [index, higherRoute] of routes.entries()) {\n\t\tfor (const lowerRoute of routes.slice(index + 1)) {\n\t\t\tdetectRouteCollision(higherRoute, lowerRoute, config, logger);\n\t\t}\n\t}\n\n\tconst i18n = settings.config.i18n;\n\tif (i18n) {\n\t\tconst strategy = toRoutingStrategy(i18n.routing, i18n.domains);\n\t\t// First we check if the user doesn't have an index page.\n\t\tif (strategy === 'pathname-prefix-always') {\n\t\t\tlet index = routes.find((route) => route.route === '/');\n\t\t\tif (!index) {\n\t\t\t\tlet relativePath = path.relative(\n\t\t\t\t\tfileURLToPath(settings.config.root),\n\t\t\t\t\tfileURLToPath(new URL('pages', settings.config.srcDir)),\n\t\t\t\t);\n\t\t\t\tthrow new AstroError({\n\t\t\t\t\t...MissingIndexForInternationalization,\n\t\t\t\t\tmessage: MissingIndexForInternationalization.message(i18n.defaultLocale),\n\t\t\t\t\thint: MissingIndexForInternationalization.hint(relativePath),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tcreateI18nFallbackRoutes(routes, i18n, config);\n\t}\n\n\tif (dev) {\n\t\t// In SSR, a 404 route is injected in the App directly for some special handling,\n\t\t// it must not appear in the manifest\n\t\tensure404Route({ routes });\n\t}\n\tif (dev || settings.buildOutput === 'server') {\n\t\tinjectImageEndpoint(settings, { routes }, dev ? 'dev' : 'build');\n\t}","sourceCodeStart":756,"sourceCodeEnd":792,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/core/routing/create-manifest.ts#L756-L792","documentation":"With i18n routing strategy `pathname-prefix-always` (`routing.prefixDefaultLocale: true`, or domains-based always-prefix), every URL — including the default locale's — carries a locale prefix, so Astro must generate a root `/` → `/${defaultLocale}` redirect. That redirect needs a root index page to exist; if no route equals `/`, manifest creation throws `MissingIndexForInternationalization` with a hint pointing at your pages directory.","triggerScenarios":"Configuring `i18n: { defaultLocale: 'en', routing: { prefixDefaultLocale: true } }` while `src/pages/index.astro` does not exist; deleting or renaming the root index during a redesign; moving the index inside a `[locale]` dynamic folder so no literal `/` route remains.","commonSituations":"Enabling always-prefixed locales on a site that previously served `/` directly; teams structuring all pages under `src/pages/[locale]/` and forgetting the root shim; fresh i18n adoption from the i18n guide without the index step.","solutions":["Create `src/pages/index.astro` (even a minimal redirect/landing page) at the project root pages dir","If `/` should serve the default locale unprefixed, switch strategy: set `routing: { prefixDefaultLocale: false }` (pathname-prefix-other-locales)","Verify the file lives at the exact `srcDir/pages` location shown in the error's hint"],"exampleFix":"# before — i18n with prefixDefaultLocale: true and no src/pages/index.astro\n\n# after — option 1: add the root page\necho '<html><body>redirect target</body></html>' > src/pages/index.astro\n\n# after — option 2: astro.config.mjs\ni18n: { defaultLocale: 'en', routing: { prefixDefaultLocale: false } }","handlingStrategy":"validation","validationCode":"// Config sanity check: always-prefix i18n requires a root index page\nimport { existsSync } from 'node:fs';\nconst alwaysPrefix = config.i18n?.routing?.prefixDefaultLocale === true;\nif (alwaysPrefix && !existsSync('src/pages/index.astro')) {\n  throw new Error('i18n pathname-prefix-always requires src/pages/index.astro');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Create `src/pages/index.astro` in the same commit that enables `prefixDefaultLocale: true`","Keep the root index out of `[locale]` folders — it must be a literal `/` route","Decide the prefix strategy before structuring pages under locale folders"],"tags":["i18n","routing","config","build","localization"],"backgroundTag":"i18n-missing-index-page","analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}