Skip to content
← Back to rules

nextjs/no-title-in-document-head 정확성

작동 방식

next/documentHead 컴포넌트에서 <title> 사용을 막습니다.

왜 나쁜가요?

<title> 요소는 모든 페이지에 공통적인 <head> 코드에서만 사용되어야 합니다. 제목 태그는 페이지 수준에서 next/head를 사용하여 정의해야 합니다.

예시

이 규칙에 부적절한 코드 예시:

javascript
import { Head } from "next/document";

export function Home() {
  return (
    <div>
      <Head>
        <title>내 페이지 제목</title>
      </Head>
    </div>
  );
}

이 규칙에 적절한 코드 예시:

javascript
import Head from "next/head";

export function Home() {
  return (
    <div>
      <Head>
        <title>내 페이지 제목</title>
      </Head>
    </div>
  );
}

사용 방법

이 규칙을 구성 파일 또는 명령줄 인터페이스에서 활성화하려면 다음을 사용할 수 있습니다:

json
{
  "plugins": ["nextjs"],
  "rules": {
    "nextjs/no-title-in-document-head": "error"
  }
}
bash
oxlint --deny nextjs/no-title-in-document-head --nextjs-plugin

참고자료