Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

In Nuxt, you can access the page title in the head object of your component file. You can set the title dynamically using Vue's computed properties.

Here's an example:

<template>
  <div>
    <h1>{{ greeting }}</h1>
  </div>
</template>

<script>
export default {
  computed: {
    greeting() {
      return 'Hello, world!'
    },
  },

  head() {
    return {
      title: this.greeting,
    }
  },
}
</script>

In this example, we set the title attribute of the head object to the value of the greeting computed property. This sets the page title to "Hello, world!"

You can also set other head attributes such as meta, base, link, script, and more. See the Nuxt documentation on the head method for more information.