【Nuxt】metaタグが重複する問題を回避する
nuxt.config.jsにこんな感じでmetaタグ書いて
head: { meta: [ { name: 'description', content: 'Meta description' } ] }
pagesで同じdescriptionタグをこんな感じで書く
head() { return { meta: [ { name: 'description', content: 'My custom description' } ] } }
そうするとmetaタグが2つ作られて重複する。
回避方法としてはhid
という一意で識別出来るプロパティを指定する。こんな感じ↓
head: { meta: [ { hid:'description', name: 'description', content: 'Meta description' } ] }
To avoid duplicated meta tags when used in child component, set up a unique identifier with the hid key for your meta elements (read more ).
普通に書いてあったのでちゃんと読まなきゃだめやなとおもた