From d48f40ded966a8bb784eb9061ca383656f73bd16 Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Sat, 27 Apr 2024 10:15:03 -0700 Subject: [PATCH] Document multilingual 404 redirects --- content/en/getting-started/configuration.md | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/content/en/getting-started/configuration.md b/content/en/getting-started/configuration.md index d7c5ea1b6..1bafc5fde 100644 --- a/content/en/getting-started/configuration.md +++ b/content/en/getting-started/configuration.md @@ -619,6 +619,39 @@ to = "/404.html" status = 404 {{< /code-toggle >}} +With a multilingual site, define the redirect for the default content language last: + +{{< code-toggle file=config/development/server >}} +defaultContentLanguage = 'en' +defaultContentLanguageInSubdir = false +[[redirects]] +from = '/fr/**' +to = '/fr/404.html' +status = 404 + +[[redirects]] # Default language must be last. +from = '/**' +to = '/404.html' +status = 404 +{{< /code-toggle >}} + +If you are serving the default content language from a subdirectory: + +{{< code-toggle file=config/development/server >}} +defaultContentLanguage = 'en' +defaultContentLanguageInSubdir = true +[[redirects]] +from = '/fr/**' +to = '/fr/404.html' +status = 404 + +[[redirects]] # Default language must be last. +from = '/**' +to = '/en/404.html' +status = 404 +{{< /code-toggle >}} + + ## Configure title case By default, Hugo follows the capitalization rules published in the [Associated Press Stylebook] when creating automatic section titles, and when transforming strings with the [`strings.Title`] function.