I try to customize the default page from Nuxt app but the documentation is very poor :
https://nuxtjs.org/guide/views#document
What if i want to get only the title for example ? or only the links in the head ?
{{ HEAD.links }}
or only the meta ?
{{ HEAD.meta }}
I don't know the syntax, is this handlebars or something equivalent ?
Thank you !
if you look in the source code, you can found only 4 custom meta:
see https://github.com/nuxt/nuxt.js/blob/ef7a42649dcee7e65886b2db1a329deecd93aff2/lib/core/meta.js#L40-L45
the HEAD meta is not an object, but an string concat:
// Get vue-meta context
const m = await this.getMeta(url)
...
// HEAD tags
meta.HEAD =
m.meta.text() +
m.title.text() +
m.link.text() +
m.style.text() +
m.script.text() +
m.noscript.text()
so you cannot get {{ HEAD.links }}
But, from your nuxt.config.js file, you can override all that HEAD data.
eg. if you want only keep the title:
replace:
head: {
title: 'starter',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: 'Nuxt.js project' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
}
by:
head: {
title: 'starter'
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With