Astro throws “Index page not found” when your i18n config sets prefixDefaultLocale: true and redirectToDefaultLocale: true, but there is no root page at src/pages/index.astro. Astro needs a route at / to attach the redirect to /en/ (or your default locale). Create a root index page, even a minimal one, and the build passes.
Key Takeaways
- The error only appears with both
prefixDefaultLocaleandredirectToDefaultLocaleset totrue.- Astro redirects
/to/<defaultLocale>/, which needs a route at/.- Any index file works:
index.astro,index.mdorindex.mdxinsrc/pages/.- The page’s content is rarely seen, but it is the fallback if the redirect does not run.
- Turning
redirectToDefaultLocaleoff removes the requirement.
The error
Index page not found.
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. (`/en`)
Hint: Create an index page (`index.astro, index.md, etc.`) in `src/pages`.
Why it happens
With a prefixed default locale, all your pages live under locale folders:
src/pages/
en/
index.astro
about.astro
fr/
index.astro
about.astro
Nothing exists at /. When redirectToDefaultLocale is on, Astro’s i18n routing sends visitors at / to /en/, and it hooks that redirect onto the root route. Without src/pages/index.astro, there is no root route, so Astro stops while building its route list.
Fix: add a root index page
---
// src/pages/index.astro
---
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="refresh" content="0;url=/en/" />
<link rel="canonical" href="/en/" />
<title>Redirecting</title>
</head>
<body>
<p><a href="/en/">Continue to the English site</a>.</p>
</body>
</html>
Astro handles the redirect itself; the meta refresh and link are a fallback for hosts or setups where the redirect does not run, and they cost nothing. Use your real default locale and your trailingSlash style in the URLs. The trailing slash tip explains which to choose.
Alternative: drop the redirect
If you do not want Astro to redirect /, turn the option off:
// astro.config.mjs
import { defineConfig } from 'astro/config';
export default defineConfig({
i18n: {
defaultLocale: 'en',
locales: ['en', 'fr'],
routing: {
prefixDefaultLocale: true,
redirectToDefaultLocale: false,
},
},
});
Then src/pages/index.astro is optional, and you can make it a language picker instead. If you set prefixDefaultLocale: false, the default locale’s pages live at the root anyway, and src/pages/index.astro is simply your English home page.
Note the opposite mistake: redirectToDefaultLocale: true with prefixDefaultLocale: false is rejected as a configuration error. Our Astro i18n routing guide compares the strategies, the pages and routing docs cover file routes, and the official internationalization guide lists all options. When you add i18n to a theme, move its homepage into src/pages/en/ and leave a minimal root page like the one above; you can browse Astro themes to compare homepage layouts.
FAQ
Why does Astro need an index page for i18n?
With prefixDefaultLocale and redirectToDefaultLocale both on, Astro attaches the redirect from / to the default locale onto the root route. That route only exists if there is an index page at src/pages/.
What should the root index page contain?
A minimal page with a link to the default locale is enough, because Astro redirects visitors before they see it. A meta refresh adds a fallback.
Can I use a language picker at the root instead?
Yes. Set redirectToDefaultLocale: false and build src/pages/index.astro as a page that links to each locale.