rsnext/errors/no-title-in-document-head.md
Houssein Djirdeh 656c2ef649
ESLint Plugin: Disallow <title> in Head from next/document (#24868)
Adds lint rule warning to the Next.js ESLint plugin to disallow `<title>` in `Head` imported from `next/document`.
2021-05-07 08:49:37 +00:00

758 B

No Title in Document Head

Why This Error Occurred

A <title> element was defined within the Head component imported from next/document, which should only be used for any <head> code that is common for all pages. Title tags should be defined at the page-level using next/head.

Possible Ways to Fix It

Within a page or component, import and use next/head to define a page title:

import Head from 'next/head'

export class Home {
  render() {
    return (
      <div>
        <Head>
          <title>My page title</title>
        </Head>
      </div>
    )
  }
}