Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

238
Views
How to set HTML lang attribute for a specific page in Next.js?

I have a Next.js website with multiple pages.

All pages are in English except one which is in French which doesn't have an English version of it.

How can I set the HTML tag lang attribute on that specific page?

This is not something I could achieve using next/head or with a custom document.

My _document.js class currently looks like this, so that English is the default 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>
  )
}

What I would need is to dynamically set the lang attribute value to fr for one specific page.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think for this, one the easiest solution could be layouts.

You can read more about here

https://nextjs.org/docs/basic-features/layouts

And add Next custom Tags

https://nextjs.org/docs/advanced-features/custom-document

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!