Usage
TheuseHead composable allows you to manage your head tags in a programmatic and reactive way, powered by Unhead. It lets you customize the meta tags, links, scripts, and other elements in the <head> section of your HTML document.
[app/app.vue]
The properties of
useHead can be dynamic, accepting ref, computed and reactive properties. The meta parameter can also accept a function returning an object to make the entire object reactive.Parameters
An object accepting head metadata properties to customize the page’s
<head> section. All properties support reactive values (ref, computed, reactive) or can be a function returning the metadata object.Sets the page title.
Configures a dynamic template to customize the page title. Can be a string with
%s placeholder or a function.Sets the
<base> tag for the document.Array of link objects. Each element is mapped to a
<link> tag, where object properties correspond to HTML attributes.Array of meta objects. Each element is mapped to a
<meta> tag, where object properties correspond to HTML attributes.Array of style objects. Each element is mapped to a
<style> tag, where object properties correspond to HTML attributes.Array of script objects. Each element is mapped to a
<script> tag, where object properties correspond to HTML attributes.Array of noscript objects. Each element is mapped to a
<noscript> tag, where object properties correspond to HTML attributes.Sets attributes of the
<html> tag. Each object property is mapped to the corresponding attribute.Sets attributes of the
<body> tag. Each object property is mapped to the corresponding attribute.Return Values
Examples
Basic Meta Tags
[app/pages/about.vue]
Reactive Meta Tags
[app/pages/profile.vue]
Using a Function for Full Reactivity
[app/pages/dynamic.vue]
Adding External Scripts and Styles
[app/pages/external.vue]
Body and HTML Attributes
[app/pages/themed.vue]