Server-render locale lang and JSON-LD inLanguage on localized pages
Merged
EL
3d ago+491+491+012345678901234567890123456789-146-146-012345678901234567890123456789
Localized landing URLs such as /de and /pt-BR now server-render <html lang> for that locale. English pages stay en.
The [locale] segment sits under the root layout, so the layout cannot read it as a param. Proxy derives x-landing-locale from the public path (and drops a client-supplied value on other URLs). The root layout uses that header for lang and for the site-wide JSON-LD graph.
On a localized landing page:
WebSiteandSoftwareApplicationgetinLanguageset to the locale (de,pt-BR,zh-CN, and the rest).WebSite.urlis the localized home (https://www.getinboxzero.com/de).Organization.urlstays the company homepage. There is no WebPage node in this graph.- The client script in
BasicLayoutthat setdocument.documentElement.langis removed. The client provider still updateslangon client navigations and for the app locale cookie.
English /, /home, and /pricing stay prerendered (dynamic = "force-static"). Localized landing routes are server-rendered on demand, because the root layout has to read the request. Other routes that render this layout and do not opt into static rendering are on demand as well.
Validation:
- Unit tests for the locale header, proxy matcher, and JSON-LD graph.
next build(typecheck included).- Production
next start:/is prerendered withlang="en"and noinLanguage./de,/fr,/pt-BR, and/zh-CNrespond with the matchinglang,inLanguage, and localizedWebSite.url. The olddocument.documentElement.langscript is gone.


Summary by CodeRabbit
- Improvements
- English landing pages, including home, pricing, login, and brand pages, are prerendered for faster delivery.
- Localized landing pages display the appropriate language in page metadata and search-engine information.
- Document requests are handled across a wider range of page routes; static and image asset routes are excluded.
- Markdown responses are available for the home and pricing pages.
- Bug Fixes
- English requests no longer retain a client-supplied landing locale, while localized requests use the locale in their URL.