I have a website built with Next.js that consists of several pages.
Most of the pages are in English, but there is one page that is in French and does not have an English version.
How can I assign the lang
attribute to the HTML tag for this specific page?
Using the next/head or a custom document has proven ineffective in achieving this.
Currently, my _document.js
class is set up like this to make English the default language for all pages:
import { Html, Head, Main, NextScript } from 'next/document'
export default function Document() {
return (
<Html lang="en">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
However, I am looking for a solution to dynamically change the value of the lang
attribute to fr
for just one specific page.