diff --git a/ssr/render.tsx b/ssr/render.tsx index 7859de7d28bc..1bbf62e7894c 100644 --- a/ssr/render.tsx +++ b/ssr/render.tsx @@ -76,6 +76,10 @@ export default function render( blogMeta = null, }: HydrationData = { url } ) { + if (!locale) { + locale = (doc && doc.locale) || DEFAULT_LOCALE; + } + const canonicalURL = `${BASE_URL}${url}`; let realPageTitle = pageTitle; @@ -139,10 +143,7 @@ export default function render( } // Open Graph protocol expects `language_TERRITORY` format. - const ogLocale = (locale || (doc && doc.locale) || DEFAULT_LOCALE).replace( - "-", - "_" - ); + const ogLocale = locale.replace("-", "_"); if (locale === "de") { // Prevent experimental German locale from being indexed. @@ -158,7 +159,7 @@ export default function render( return ( "" + renderToString( - +