Guides

Title Template

Learn how to set a title template for your site.

Title templates allow you to render your page titles in a uniform way.

titleTemplate

Using the titleTemplate key allows you to set a template for your page titles.

Title template can either be:

  • A string with a %s, that is replaced with the title
  • A function which has an optional title as the only argument and returns a string

String

useHead({
  titleTemplate: 'My Site - %s',
})

Function

useHead({
  titleTemplate: (title?: string) => `${title} - My Site`,
})

Disabling titleTemplate

If you want to disable the title template for a specific page, you can set titleTemplate to null.

useHead({
  titleTemplate: null,
})

Examples

Setting a default title

useHead({
  titleTemplate: (title?: string) => !title ? 'Default title' : `${title} - My Site`,
})