Based on the knowledge sources, your goal is to have the root URL (/) serve your default locale’s content without a language prefix (e.g., /en/), even though you’re using a dynamic catch-all like [...locale] for localized routes.
Astro’s i18n routing supports this scenario using the prefixDefaultLocale: false option. With this configuration:
- The default locale’s pages (e.g., English) are placed directly in the root of
src/pages/ (not in an /en/ folder).
- Other locales are placed in their respective folders (e.g.,
src/pages/fr/).
- The root URL
/ and routes like /about will serve the default locale, without a language prefix.
- URLs like
/fr/about will serve the French version.
Example configuration:
import { defineConfig } from "astro/config";
export default defineConfig({
i18n: {
locales: ["en", "fr"],
defaultLocale: "en",
routing: {
prefixDefaultLocale: false
}
}
});
Example folder structure:
src/
pages/
index.astro // default locale (en)
about.astro // default locale (en)
fr/
index.astro // French
about.astro // French
With this setup, visiting / will show your default locale (English) without a /en/ prefix, and /fr/ will show French content. You do not need to redirect / to /en/—the root will serve the default language directly, as you want.
Note:
If you use a dynamic [...locale].astro catch-all, you may need to ensure that your root index.astro exists and is not overridden by the catch-all route, as Astro requires a root index page for proper routing and redirection logic, especially with i18n enabled [i18n routing reference].