Nuxt.js: Set title dynamically

Created on 25 May 2017  路  4Comments  路  Source: nuxt/nuxt.js

As we always see, notifications can be show in title, so when I get the unread notifications count form API, I want to show this count in title , like:

(2)page title

But the nuxt title is configured, I didn't find the proper way to set it dynamically.

How can I resolve this?

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

Most helpful comment

@motia Thanks! this works, just put this to layouts/default.vue

All 4 comments

Hi @bimohxh , you can try this in the top component that shows notifications number.

  head () {
    return {
      titleTemplate: `(${this.$store.notificationNumber}) %s`
    }
  },

@motia Thanks! this works, just put this to layouts/default.vue

what about the description can we update that dynamically.
Dynamically means on each search meta title and description will update.

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

bimohxh picture bimohxh  路  3Comments

VincentLoy picture VincentLoy  路  3Comments

danieloprado picture danieloprado  路  3Comments

vadimsg picture vadimsg  路  3Comments

jaredreich picture jaredreich  路  3Comments