Skip to content

Files

Latest commit

 

History

History
42 lines (36 loc) · 729 Bytes

no-title-in-document-head.md

File metadata and controls

42 lines (36 loc) · 729 Bytes

Pattern: Title in document head

Issue: -

Description

Title tags should not be added in pages/_document.js as they will be static and cannot be changed dynamically. Use title tags in individual pages or _app.js instead.

Examples

Example of incorrect code:

// pages/_document.js
export default function Document() {
  return (
    <Html>
      <Head>
        <title>Static Title</title>
      </Head>
      <body>
        <Main />
        <NextScript />
      </body>
    </Html>
  )
}

Example of correct code:

// pages/index.js
export default function Page() {
  return (
    <>
      <Head>
        <title>Dynamic Page Title</title>
      </Head>
      <main>Content</main>
    </>
  )
}