head: {
titleTemplate: "網站標題",
meta: [
{ charset: "utf-8" },
{ name: "keywords", content: "網站搜索關鍵字" },
{name: "description", content: "網站描述" }
]
}
如上代碼,正常情況下輸入的網頁源代碼是這樣子的:
<head data-n-head="">
<title data-n-head="true">網站標題</title>
<meta data-n-head="true" charset="utf-8">
<meta data-n-head="true" name="viewport" content="width=device-width, initial-scale=1">
<meta data-n-head="true" data-hid="description" name="description" content="My peachy Nuxt.js project">
<meta data-n-head="true" charset="utf-8">
<meta data-n-head="true" name="keywords" content="網站搜索關鍵字">
<meta data-n-head="true" name="description" content="網站描述">
</head>
這樣子會有兩個description。
要解決這個問題很簡單,加上一個唯一標識hid:'description'
如下代碼:
head: {
titleTemplate: "網站標題",
meta: [
{ charset: "utf-8" },
{ name: "keywords", content: "網站搜索關鍵字" },
{ hid: "description", name: "description", content: "網站描述" }
]
}
輸入網頁源代碼爲:
<head data-n-head="">
<title data-n-head="true">網站標題</title>
<meta data-n-head="true" charset="utf-8">
<meta data-n-head="true" name="viewport" content="width=device-width, initial-scale=1">
<meta data-n-head="true" charset="utf-8">
<meta data-n-head="true" name="keywords" content="網站搜索關鍵字">
<meta data-n-head="true" data-hid="description" name="description" content="網站描述">
</head>
她那時候還太年輕,不知道所有命運贈送的禮物,早已在暗中標好了價格。
——斯蒂芬·茨威格《斷頭王后》