I'm working on a multilange static landing page in a Next.Js project. My goal is to have the following structure:
- / -> English Home page
- /de -> German Home page
- /it -> Italian Home page
I'm building it in the following way:
pages/index.js
export default function Home() {
return <div>English Homepage</div>
}
pages/de.js
export default function Home() {
return <div>German page</div>
}
In order to make the website accessible, I would like to set html lang accordingly.
pages/_document.js
class MyDocument extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx)
return { ...initialProps }
}
render() {
return (
<Html lang={???}>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}
How can I specify the language per page?
I tried with getInitialProps, but that forces my website to be SSR.