文件標題遺失
防止在
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>
)
}
實用連結
這有幫助嗎?