---
title: "How to Set Page Titles in Vue 3"
description: "Set dynamic page titles in Vue 3 with useHead. Learn title templates, reactive titles, and SSR patterns that Google indexes correctly."
canonical_url: "https://nuxtseo.com/learn-seo/vue/mastering-meta/titles"
last_updated: "2026-07-16"
---

<key-takeaways>

- Use `useHead()` instead of `document.title` for SSR compatibility
- Add a title template to append your site name consistently
- Keep titles under 60 characters: longer titles get truncated and are far more likely to be rewritten
- Set `og:title` separately for social sharing

</key-takeaways>

Page titles appear in browser tabs and as the clickable headline in search results. Google keeps your `<title>` tag as-is [around 87% of the time](https://developers.google.com/search/blog/2021/09/more-info-about-titles). Third-party studies that count any modification, including truncation and casing changes, put the figure closer to [76% of titles changed in some way](https://searchengineland.com/google-changed-76-of-title-tags-in-q1-2025-heres-what-that-means-454847), so a well-formed title is your best shot at controlling what searchers see.

```html
<head>
  <title>Mastering Titles in Vue · Vue SEO</title>
</head>
```

Setting titles in Vue 3 requires a head manager like [Unhead](https://unhead.unjs.io/) since `document.title` won't work during server-side rendering.

## Quick Reference

```vue
<script setup lang="ts">
import { useHead } from '@unhead/vue'

// Basic title
useHead({ title: 'Home' })

// With template (adds site name)
useHead({
  title: 'Home',
  titleTemplate: '%s | MySite'
})
</script>
```

```vue
<script setup lang="ts">
import { useHead } from '@unhead/vue'
import { ref } from 'vue'

// Reactive title from data
const post = ref({ title: 'Loading...' })
useHead({
  title: () => post.value.title
})
</script>
```

```vue
<script setup lang="ts">
import { useSeoMeta } from '@unhead/vue'

// SEO-focused (includes og:title)
useSeoMeta({
  title: 'Home',
  ogTitle: 'Home | MySite'
})
</script>
```

## Why Not `document.title`?

You might try setting titles directly:

```ts
// ❌ Breaks SSR, may not be indexed
document.title = 'Home'
```

This fails during server-side rendering: the title won't exist in the initial HTML response. Search engines render JavaScript but [may not wait](https://developers.google.com/search/docs/crawling-indexing/javascript/javascript-seo-basics) for client-side updates.

<warning>

Using `document.title` in a Vue SPA means search engines may index your pages with missing or incorrect titles. Always use a head manager like Unhead for SEO-critical metadata.

</warning>

Use [Unhead](https://unhead.unjs.io/) instead. It handles both SSR and client-side updates. For Google's official guidance, see [Influencing your title links](https://developers.google.com/search/docs/appearance/title-link).

## Setting Titles with `useHead()`

The [`useHead()`](https://unhead.unjs.io/docs/head/api/composables/use-head) composable sets titles that work in SSR and client-side navigation:

```vue [input.vue]twoslash
<script setup lang="ts">
import { useHead } from '@unhead/vue'

useHead({
  title: 'Home'
})
</script>
```

```html [output.html]
<head>
  <title>Home</title>
</head>
```

Works in any component. You can set other head tags in the same call:

```vue
<script setup lang="ts">
import { useHead } from '@unhead/vue'

useHead({
  title: 'Home',
  meta: [
    { name: 'description', content: 'Welcome to MyApp' }
  ]
})
</script>
```

### Reactive Titles

<tip>

Unhead accepts refs, reactive objects, and computed values. Pass the reactive reference directly; don't destructure it with `.value`.

</tip>

<code-group>

```vue [Bad]
<script setup lang="ts">
import { useHead } from '@unhead/vue'
import { ref } from 'vue'

const myTitle = ref('Home')

// Loses reactivity
useHead({
  title: myTitle.value
})
</script>
```

```vue [Good]
<script setup lang="ts">
import { useHead } from '@unhead/vue'
import { ref } from 'vue'

const myTitle = ref('Home')

// Stays reactive
useHead({
  title: myTitle
})
</script>
```

</code-group>

Computed getter syntax works for derived titles:

```vue
<script setup lang="ts">
import { useHead } from '@unhead/vue'
import { ref } from 'vue'

const post = ref({ title: 'Loading...' })

useHead({
  title: () => post.value.title // Updates when post changes
})
</script>
```

### SSR and SEO

Fetch data before render, not in `onMounted()`. Client-only fetches mean search engines see your loading state:

```vue
<script setup lang="ts">
import { useHead } from '@unhead/vue'
import { onMounted, ref } from 'vue'

const postTitle = ref('Loading...')
useHead({ title: postTitle })

// ❌ onMounted runs after SSR. Google sees "Loading..."
onMounted(() => {
  (async () => {
    postTitle.value = (await fetchPostData()).title
  })()
})
</script>
```

Use SSR-compatible data fetching (Vue's `onServerPrefetch()` or framework solutions like Nuxt's `useFetch()`).

## Title Templates

Most sites append a site name to titles for brand recognition. [Google recommends](https://developers.google.com/search/docs/appearance/title-link#page-titles) adding your site name with a delimiter:

```html
<head>
  <title>Home | MySite</title>
</head>
```

Use `titleTemplate` with a [title template](https://unhead.unjs.io/docs/head/guides/core-concepts/titles):

```vue [input.vue]twoslash
<script setup lang="ts">
import { useHead } from '@unhead/vue'

useHead({
  title: 'Home',
  titleTemplate: '%s | MySite'
})
</script>
```

```html [output.html]
<head>
  <title>Home | MySite</title>
</head>
```

The `%s` token gets replaced with your page title (or empty string if none set).

Override the template for specific pages by passing `null`:

```vue [input.vue]
<script lang="ts" setup>
import { useHead } from '@unhead/vue'

useHead({
  title: 'Home',
  titleTemplate: null
})
</script>
```

```html [output.html]
<head>
  <title>Home</title>
</head>
```

## Template Params

For dynamic site names or separators, register the [Template Params plugin](https://unhead.unjs.io/docs/head/guides/plugins/template-params) when creating your head instance:

```ts
import { createHead } from '@unhead/vue/client'
import { TemplateParamsPlugin } from '@unhead/vue/plugins'

const head = createHead({
  plugins: [TemplateParamsPlugin()]
})
```

Then use custom params:

```vue [input.vue]twoslash
<script setup lang="ts">
import { useHead } from '@unhead/vue'

useHead({
  title: 'Home',
  titleTemplate: '%s %separator %siteName',
  templateParams: {
    separator: '·',
    siteName: 'MySite'
  }
})
</script>
```

```html [output.html]
<head>
  <title>Home · MySite</title>
</head>
```

Common separators: `|` `-` `.` `•` `·`

Template params work in meta tags too:

```vue
<script setup lang="ts">
import { useHead } from '@unhead/vue'

useHead({
  templateParams: { siteName: 'MyApp' },
  title: 'Home',
  meta: [
    { name: 'description', content: 'Welcome to %siteName' },
    { property: 'og:title', content: 'Home | %siteName' }
  ]
})
</script>
```

## Social Share Titles

Social platforms use `og:title` and `twitter:title` meta tags. Use [`useSeoMeta()`](https://unhead.unjs.io/docs/head/api/composables/use-seo-meta) to set these:

<figure-image alt="Nuxt X Share" lazy="true" src="/nuxt-x-share.png">



</figure-image>

```vue [input.vue]
<script setup lang="ts">
import { useSeoMeta } from '@unhead/vue'

useSeoMeta({
  title: 'Why you should eat more broccoli',
  titleTemplate: '%s | Health Tips',
  // og:title ignores titleTemplate, set it explicitly
  ogTitle: 'Health Tips: 10 reasons to eat more broccoli',
  // twitter:title only needed if different from og:title
  twitterTitle: 'Hey X! 10 reasons to eat more broccoli',
})
</script>
```

```html [output.html]
<head>
  <title>Why you should eat more broccoli | Health Tips</title>
  <meta property="og:title" content="Health Tips: 10 reasons to eat more broccoli" />
  <meta name="twitter:title" content="Hey X! 10 reasons to eat more broccoli" />
</head>
```

Twitter/X falls back to `og:title` if `twitter:title` isn't set.

## Titles for AI Search

AI answer engines categorize pages by intent before deciding what to cite. A vague title like "Meta Tags" gives them nothing to work with; "How to Set Meta Tags in Vue 3" signals a tutorial, "Vue 3 Meta Tag API Reference" signals documentation. Say what the page is in the title.

## Title Length

Google truncates titles at roughly 600px of display width, which works out to 50-60 characters depending on the letters used. The cutoff is pixel-based, so two titles of identical length can truncate differently.

Length also affects rewrites. [Zyppy's study of 80,000+ titles](https://zyppy.com/seo/google-title-rewrite-study/) found the 51-60 character range had the lowest rewrite rates (39-42%), while titles over 70 characters were rewritten every time. A [2025 follow-up study](https://searchengineland.com/google-changed-76-of-title-tags-in-q1-2025-heres-what-that-means-454847) found titles Google left unchanged averaged 44 characters.

Longer titles still get indexed; Google only truncates the display. Front-load important keywords since users may only see the first 50 characters.

## Vue Router Integration

Set titles from route meta for centralized title management:

```ts
// router.ts
const routes = [
  { path: '/', component: Home, meta: { title: 'Home' } },
  { path: '/about', component: About, meta: { title: 'About Us' } },
  { path: '/blog/:slug', component: BlogPost, meta: { title: 'Blog' } }
]
```

Use a navigation guard to apply titles on route change:

```ts
import { useHead } from '@unhead/vue'

router.afterEach((to) => {
  const title = to.meta.title as string
  if (title) {
    useHead({ title })
  }
})
```

For dynamic routes, override in the component:

```vue
<script setup lang="ts">
import { useHead } from '@unhead/vue'

// Fetched post data overrides route meta
const post = await fetchPost(route.params.slug)

useHead({
  title: post.title // "How to Build a Blog" instead of generic "Blog"
})
</script>
```

Set a global title template in your guard:

```ts
import { useHead } from '@unhead/vue'

router.afterEach((to) => {
  useHead({
    title: to.meta.title as string || 'MySite',
    titleTemplate: '%s | MySite'
  })
})
```

Handle nested routes by walking matched routes:

```ts
import { useHead } from '@unhead/vue'

router.afterEach((to) => {
  // Find deepest route with a title
  const title = to.matched.toReversed()
    .find(r => r.meta.title)
    ?.meta
    .title as string

  if (title)
    useHead({ title })
})
```

Using Nuxt? Check out [Nuxt SEO](/docs/nuxt-seo/getting-started/introduction) which handles much of this automatically. [Learn more about Page Titles in Nuxt →](/learn-seo/nuxt/mastering-meta/titles)

## Checklist

<checklist id="vue-titles">

- Use `useHead()` or `useSeoMeta()` instead of `document.title`
- Set up a title template with your site name
- Keep titles under 60 characters
- Set `og:title` for social sharing
- Fetch data server-side for dynamic titles
- Test titles render correctly in SSR

</checklist>
