文件中缺少標題 (No Title in Document Head)
避免在從 `next/document` 導入的 `Head` 元件中使用 `<title>` 標籤。
錯誤原因
在從 `next/document` 導入的 `Head` 元件中定義了 `<title>` 元素,該元件應該只用於所有頁面通用的 `<head>` 程式碼。標題標籤應該在頁面層級使用 `next/head` 來定義。
可能的解決方法
在頁面或元件中,導入並使用 `next/head` 來定義頁面標題。
pages/index.js
import Head from 'next/head'
export function Home() {
return (
<div>
<Head>
<title>My page title</title>
</Head>
</div>
)
}
實用連結
這對您有幫助嗎?