Nuxt.js: head method does not work with mode: spa

Created on 1 Dec 2017  路  6Comments  路  Source: nuxt/nuxt.js

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/

This question is available on Nuxt.js community (#c2010)
question

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?

All 6 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gary149 picture gary149  路  3Comments

maicong picture maicong  路  3Comments

bimohxh picture bimohxh  路  3Comments

msudgh picture msudgh  路  3Comments

VincentLoy picture VincentLoy  路  3Comments