Nuxt Config
Set static head tags for your entire app using theapp.head property in your nuxt.config.ts:
This method does not support reactive data. Use
useHead() in app.vue for reactive meta tags.Default Tags
Nuxt provides these default tags to ensure your website works well out of the box:- viewport:
width=device-width, initial-scale=1 - charset:
utf-8
useHead Composable
Use theuseHead composable to manage head tags programmatically with full reactive support:
useHead and useHeadSafe composables in the API documentation.
useSeoMeta Composable
UseuseSeoMeta to define SEO meta tags as a type-safe object, helping you avoid typos and common mistakes:
name instead of property for Open Graph tags.
Meta Components
If you prefer defining head tags in your template, Nuxt provides these components:<Title>, <Base>, <NoScript>, <Style>, <Meta>, <Link>, <Body>, <Html>, and <Head>.
Note the capitalization of these components to avoid conflicts with native HTML tags.
Reactivity
All head properties support reactivity through computed values, getters, or reactive objects:Title Templates
UsetitleTemplate to provide a dynamic template for customizing page titles. The template can be a string (where %s is replaced with the title) or a function:
Set
titleTemplate in your app.vue file to apply it across all pages. You cannot use function-based templates in nuxt.config.My Page on another page, it appears as “My Page - Site Title” in the browser tab.
Template Parameters
UsetemplateParams for additional placeholders beyond the default %s:
Body Tags
UsetagPosition: 'bodyClose' to append tags to the end of the <body> tag:
'head', 'bodyClose', or 'bodyOpen'.
Practical Examples
Page-Specific Meta with definePageMeta
Set metadata based on the current route usingdefinePageMeta with useHead:
Dynamic Titles
Set dynamic page titles usingtitleTemplate:
External CSS and Fonts
Enable Google Fonts using thelink property:
Best Practices
- Use useSeoMeta for SEO: Leverage type safety to avoid common meta tag mistakes
- Set defaults in app.vue: Apply site-wide settings using
useHeadinapp.vue - Override per page: Use
definePageMetaanduseHeadin pages for page-specific meta - Keep it reactive: Use refs and computed values to update meta tags dynamically
- Follow Open Graph standards: Ensure proper
og:andtwitter:tags for social sharing