From 3621118664e76d7e34d5793d3a04087abad7eae4 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Fri, 19 Sep 2025 15:47:11 +0200 Subject: [PATCH 1/7] feat: update i18n.redirectToDefaultLocale default value --- .../docs/en/guides/internationalization.mdx | 4 +-- src/content/docs/en/guides/upgrade-to/v6.mdx | 25 +++++++++++++++++++ .../en/reference/configuration-reference.mdx | 6 ++--- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/content/docs/en/guides/internationalization.mdx b/src/content/docs/en/guides/internationalization.mdx index e210b84c37816..1c340470ed6e8 100644 --- a/src/content/docs/en/guides/internationalization.mdx +++ b/src/content/docs/en/guides/internationalization.mdx @@ -176,9 +176,9 @@ Set this option when all routes will have their `/locale/` prefix in their URL a Configures whether or not the home URL (`/`) generated by `src/pages/index.astro` will redirect to `/`. -Setting `prefixDefaultLocale: true` will also automatically set `redirectToDefaultLocale: true` in your `routing` config object. By default, the required `src/pages/index.astro` file will automatically redirect to the index page of your default locale. +By default, this allows you to have a site home page that exists outside of your configured locale folder structure. -You can opt out of this behavior by [setting `redirectToDefaultLocale: false`](/en/reference/configuration-reference/#i18nroutingredirecttodefaultlocale). This allows you to have a site home page that exists outside of your configured locale folder structure. +[Setting `prefixDefaultLocale: true`](/en/reference/configuration-reference/#i18nroutingredirecttodefaultlocale) will also automatically set `redirectToDefaultLocale: true` in your `routing` config object. The required `src/pages/index.astro` file will automatically redirect to the index page of your default locale. ### `manual` diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 41552d4979312..fdcc5bed78f16 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -108,6 +108,31 @@ Some default behavior has changed in Astro v5.0 and your project code may need u In most cases, the only action needed is to review your existing project's deployment and ensure that it continues to function as you expect, making updates to your code as necessary. In some cases, there may be a configuration setting to allow you to continue to use the previous default behavior. +### Changed: `i18n.routing.redirectToDefaultLocale` default value + +In Astro v5.0, `i18n.routing.redirectToDefaultLocale` default value as `true` and `i18n.routing.prefixDefaultLocale` default value was `false`. However, the resulting redirects could cause infinite loops. + +In Astro v6.0, `i18n.routing.redirectToDefaultLocale` now defaults to `false`. It can now only be used if `i18n.routing.prefixDefaultLocale` is set to `true`. + +#### What should I do? + +To get back to your existing behavior, review your Astro config to make sure properties have compatible values: + +```js ins={7} title="astro.config.mjs" +import { defineConfig } from 'astro/config'; + +export default defineConfig({ + i18n: { + routing: { + prefixDefaultLocale: true, + redirectToDefaultLocale: true + } + } +}) +``` + +Learn more about [Internationalization routing](/en/guides/internationalization/#routing). + ## Breaking Changes The following changes are considered breaking changes in Astro v5.0. Breaking changes may or may not provide temporary backwards compatibility. If you were using these features, you may have to update your code as recommended in each entry. diff --git a/src/content/docs/en/reference/configuration-reference.mdx b/src/content/docs/en/reference/configuration-reference.mdx index a907cadcc1a6f..c220bafec5b62 100644 --- a/src/content/docs/en/reference/configuration-reference.mdx +++ b/src/content/docs/en/reference/configuration-reference.mdx @@ -1549,14 +1549,14 @@ export default defineConfig({

**Type:** `boolean`
-**Default:** `true`
+**Default:** `false`

Configures whether or not the home URL (`/`) generated by `src/pages/index.astro` will redirect to `/[defaultLocale]` when `prefixDefaultLocale: true` is set. -Set `redirectToDefaultLocale: false` to disable this automatic redirection at the root of your site: +Set `redirectToDefaultLocale: true` to enable this automatic redirection at the root of your site: ```js // astro.config.mjs export default defineConfig({ @@ -1565,7 +1565,7 @@ export default defineConfig({ locales: ["en", "fr"], routing: { prefixDefaultLocale: true, - redirectToDefaultLocale: false + redirectToDefaultLocale: true } } }) From aa0e0a2f8183d764663aee482c73e3af53227d09 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Tue, 23 Sep 2025 18:42:02 +0200 Subject: [PATCH 2/7] feat: apply suggestion --- src/content/docs/en/guides/internationalization.mdx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/content/docs/en/guides/internationalization.mdx b/src/content/docs/en/guides/internationalization.mdx index 1c340470ed6e8..535b1653858b4 100644 --- a/src/content/docs/en/guides/internationalization.mdx +++ b/src/content/docs/en/guides/internationalization.mdx @@ -170,15 +170,13 @@ Set this option when all routes will have their `/locale/` prefix in their URL a - URLs without a locale prefix, (e.g. `example.com/about/`) will return a 404 (not found) status code unless you specify a [fallback strategy](#fallback). -### `redirectToDefaultLocale` +#### Opting out of redirects for the home URL

-Configures whether or not the home URL (`/`) generated by `src/pages/index.astro` will redirect to `/`. +Even if you *do* want default locale prefixed (e.g. all your routes to be `/en/page-1` when your default language is English), it is possible to opt-out of that behaviour for only the index page. This is useful when you want to have a site home that exists outside of your configured locale structure -By default, this allows you to have a site home page that exists outside of your configured locale folder structure. - -[Setting `prefixDefaultLocale: true`](/en/reference/configuration-reference/#i18nroutingredirecttodefaultlocale) will also automatically set `redirectToDefaultLocale: true` in your `routing` config object. The required `src/pages/index.astro` file will automatically redirect to the index page of your default locale. +When `prefixDefaultLocale: true` is set, you can optionally configure `redirectToDefaultLocale` to control the redirect behaviour of `src/pages/index.astro` (e.g. whether or not it should redirect to `src/pages/en/index.astro`). This allows all your localized routes to be prefixed **except the home URL of your site**. ### `manual` From fd8f9a6fde27b2c90fc219bf4ab069ce727133a6 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Tue, 23 Sep 2025 18:49:31 +0200 Subject: [PATCH 3/7] Apply suggestions from code review Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> --- src/content/docs/en/guides/internationalization.mdx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/content/docs/en/guides/internationalization.mdx b/src/content/docs/en/guides/internationalization.mdx index 535b1653858b4..55ed1cd93e91c 100644 --- a/src/content/docs/en/guides/internationalization.mdx +++ b/src/content/docs/en/guides/internationalization.mdx @@ -172,9 +172,7 @@ Set this option when all routes will have their `/locale/` prefix in their URL a #### Opting out of redirects for the home URL -

- -Even if you *do* want default locale prefixed (e.g. all your routes to be `/en/page-1` when your default language is English), it is possible to opt-out of that behaviour for only the index page. This is useful when you want to have a site home that exists outside of your configured locale structure +Even with your default locale routes prefixed, it is possible to opt-out of that behaviour for only your site's index page. This is useful when you want to have a home page that exists outside of your configured locale structure. When `prefixDefaultLocale: true` is set, you can optionally configure `redirectToDefaultLocale` to control the redirect behaviour of `src/pages/index.astro` (e.g. whether or not it should redirect to `src/pages/en/index.astro`). This allows all your localized routes to be prefixed **except the home URL of your site**. From c625bd7d48d4749b2bbd99d2f47df97c689d8366 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Tue, 23 Sep 2025 18:53:54 +0200 Subject: [PATCH 4/7] Update src/content/docs/en/guides/internationalization.mdx Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> --- src/content/docs/en/guides/internationalization.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/en/guides/internationalization.mdx b/src/content/docs/en/guides/internationalization.mdx index 55ed1cd93e91c..4a4f88f79c0f7 100644 --- a/src/content/docs/en/guides/internationalization.mdx +++ b/src/content/docs/en/guides/internationalization.mdx @@ -172,7 +172,7 @@ Set this option when all routes will have their `/locale/` prefix in their URL a #### Opting out of redirects for the home URL -Even with your default locale routes prefixed, it is possible to opt-out of that behaviour for only your site's index page. This is useful when you want to have a home page that exists outside of your configured locale structure. +Even with your default locale routes prefixed, this behaviour does not apply by default to your site's index page. This allows you to have a home page that exists outside of your configured locale structure, where all of your localized routes are prefixed except the home URL of your site. When `prefixDefaultLocale: true` is set, you can optionally configure `redirectToDefaultLocale` to control the redirect behaviour of `src/pages/index.astro` (e.g. whether or not it should redirect to `src/pages/en/index.astro`). This allows all your localized routes to be prefixed **except the home URL of your site**. From f47886614a81cc2888116ee5b4796e4e172d118b Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Tue, 23 Sep 2025 20:09:14 +0200 Subject: [PATCH 5/7] Update src/content/docs/en/guides/internationalization.mdx Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> --- src/content/docs/en/guides/internationalization.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/en/guides/internationalization.mdx b/src/content/docs/en/guides/internationalization.mdx index 4a4f88f79c0f7..2783c9bc447dc 100644 --- a/src/content/docs/en/guides/internationalization.mdx +++ b/src/content/docs/en/guides/internationalization.mdx @@ -174,7 +174,7 @@ Set this option when all routes will have their `/locale/` prefix in their URL a Even with your default locale routes prefixed, this behaviour does not apply by default to your site's index page. This allows you to have a home page that exists outside of your configured locale structure, where all of your localized routes are prefixed except the home URL of your site. -When `prefixDefaultLocale: true` is set, you can optionally configure `redirectToDefaultLocale` to control the redirect behaviour of `src/pages/index.astro` (e.g. whether or not it should redirect to `src/pages/en/index.astro`). This allows all your localized routes to be prefixed **except the home URL of your site**. +You can opt out of this behavior so that your main site URL will also redirect to a prefixed, localized route for your default locale. When `prefixDefaultLocale: true` is set, you can additionally configure `redirectToDefaultLocale: true`. This will ensure that `src/pages/index.astro` will redirect to `src/pages/[defaultLocale]/index.astro`. ### `manual` From 69925eff2ab8327c6f5a5434dee1148ff0080175 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Tue, 23 Sep 2025 22:15:35 +0200 Subject: [PATCH 6/7] Apply suggestions from code review Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> --- src/content/docs/en/guides/upgrade-to/v6.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index fdcc5bed78f16..9d5c68574263f 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -110,13 +110,13 @@ In most cases, the only action needed is to review your existing project's deplo ### Changed: `i18n.routing.redirectToDefaultLocale` default value -In Astro v5.0, `i18n.routing.redirectToDefaultLocale` default value as `true` and `i18n.routing.prefixDefaultLocale` default value was `false`. However, the resulting redirects could cause infinite loops. +In Astro v5.0, the `i18n.routing.redirectToDefaultLocale` default value was `true` and the `i18n.routing.prefixDefaultLocale` default value was `false`. However, the resulting redirects could cause infinite loops. -In Astro v6.0, `i18n.routing.redirectToDefaultLocale` now defaults to `false`. It can now only be used if `i18n.routing.prefixDefaultLocale` is set to `true`. +In Astro v6.0, `i18n.routing.redirectToDefaultLocale` now defaults to `false`. Additionally, it can now only be used if `i18n.routing.prefixDefaultLocale` is set to `true`. #### What should I do? -To get back to your existing behavior, review your Astro config to make sure properties have compatible values: +Review your Astro `i18n` config as you may now need to explicitly set values for `redirectToDefaultLocale` and `prefixDefaultLocale` to recreate your project's previous behavior. ```js ins={7} title="astro.config.mjs" import { defineConfig } from 'astro/config'; From 451e02ced7fc48a9a835f8d8240c804720a6a1b4 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Wed, 24 Sep 2025 13:09:42 +0200 Subject: [PATCH 7/7] Apply suggestions from code review Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> --- src/content/docs/en/guides/internationalization.mdx | 2 +- src/content/docs/en/guides/upgrade-to/v6.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/docs/en/guides/internationalization.mdx b/src/content/docs/en/guides/internationalization.mdx index 2783c9bc447dc..70b4bbdea9db8 100644 --- a/src/content/docs/en/guides/internationalization.mdx +++ b/src/content/docs/en/guides/internationalization.mdx @@ -174,7 +174,7 @@ Set this option when all routes will have their `/locale/` prefix in their URL a Even with your default locale routes prefixed, this behaviour does not apply by default to your site's index page. This allows you to have a home page that exists outside of your configured locale structure, where all of your localized routes are prefixed except the home URL of your site. -You can opt out of this behavior so that your main site URL will also redirect to a prefixed, localized route for your default locale. When `prefixDefaultLocale: true` is set, you can additionally configure `redirectToDefaultLocale: true`. This will ensure that `src/pages/index.astro` will redirect to `src/pages/[defaultLocale]/index.astro`. +You can opt out of this behavior so that your main site URL will also redirect to a prefixed, localized route for your default locale. When `prefixDefaultLocale: true` is set, you can additionally configure `redirectToDefaultLocale: true`. This will ensure that the home URL (`/`) generated by `src/pages/index.astro` will redirect to `/[defaultLocale]/`. ### `manual` diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 9d5c68574263f..3851c54002042 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -110,7 +110,7 @@ In most cases, the only action needed is to review your existing project's deplo ### Changed: `i18n.routing.redirectToDefaultLocale` default value -In Astro v5.0, the `i18n.routing.redirectToDefaultLocale` default value was `true` and the `i18n.routing.prefixDefaultLocale` default value was `false`. However, the resulting redirects could cause infinite loops. +In Astro v5.0, the `i18n.routing.redirectToDefaultLocale` default value was `true`. When combined with the `i18n.routing.prefixDefaultLocale` default value of `false`, the resulting redirects could cause infinite loops. In Astro v6.0, `i18n.routing.redirectToDefaultLocale` now defaults to `false`. Additionally, it can now only be used if `i18n.routing.prefixDefaultLocale` is set to `true`.