In nuxt.config.js:
module.exports = {
mode: 'spa',
head: {
title: 'Generic title',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: 'Generic description' }
]
}
/*
** other things
*/
}
In one of the pages (/pages/b.vue):
<script>
export default {
head () {
return {
title: 'Page B',
meta: [
{ hid: 'description', name: 'description', content: 'Page B description' }
]
}
}
}
</script>
Then "nuxt generate"
Go to /dist/b/index.html
Expect to see:
<meta data-n-head="true" content="Page B description" name="description" data-hid="description">
and
<title data-n-head="true">Page B</title>
but get:
<meta data-n-head="true" content="Generic description" name="description" data-hid="description">
and
<title data-n-head="true">Generic title</title>
Related to: https://nuxtjs.org/api/pages-head/
The generated html only contains meta info in nuxt.config.js, but if you deployed and access the site, meta within component will take effect.
Thank you for answering my question, but would it work in terms of SEO?
Yes, you're right, it may not work in SEO, we may add ssr meta in spa mode into roadmap as a feature request.
@HoraceKeung
Sorry, I have double checked, it works fine with SEO, so just ignore my last comment.
Bumping because I'm having an issue with this.
I'm trying to post pages from an SPA generated app to Facebook, and they don't seem to render the page (thus getting the full meta tags). Instead, it only shows the global meta data from nuxt.config.js. That means that every page from my site appears as the homepage, no matter what.
Is there no way I can inject my page-specific meta tags into the generated html on running nuxt generate?
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Bumping because I'm having an issue with this.
I'm trying to post pages from an SPA generated app to Facebook, and they don't seem to render the page (thus getting the full meta tags). Instead, it only shows the global meta data from nuxt.config.js. That means that every page from my site appears as the homepage, no matter what.
Is there no way I can inject my page-specific meta tags into the generated html on running nuxt generate?