--- title: "Validate" description: "Catch common SEO, resource-loading, and head-tag mistakes. Validate URLs, metadata, Open Graph fields, and likely typos." navigation.title: "Validate" --- The Validate plugin reports non-absolute URLs, missing Open Graph companions, likely meta-property typos, conflicting robots directives, and other head mistakes. It runs only when registered. ## Runtime validation The Validate plugin inspects the final resolved head output and warns about issues that TypeScript can't catch: - **URL problems**: Relative canonical or Open Graph URLs, and canonical versus `og:url` mismatches - **Missing tags**: No title, no description on an indexable page, or missing Open Graph companions - **Content issues**: Empty meta content, HTML in a title, or unresolved template params - **Conflicts**: Contradictory robots directives or accessibility-harmful viewport settings - **Typos**: Unknown meta properties or names, with fuzzy-matched suggestions ## Setup Register the plugin where you want head tag validation. It is omitted from builds that do not import it: ::code-block ```ts [Input] import { ValidatePlugin } from '@unhead/dynamic-import/plugins' const head = createHead({ plugins: [ ValidatePlugin() ] }) ``` :: By default, warnings are logged via `console.warn`. You can provide a custom reporter: ::code-block ```ts [Input] ValidatePlugin({ onReport(rules) { // rules: Array<{ id, message, severity, source?, tag? }> for (const rule of rules) { const loc = rule.source ? ` (${rule.source})` : '' console.warn(`[${rule.id}] ${rule.message}${loc}`) } } }) ``` :: ## Options ::code-block ```ts [Input] export interface ValidatePluginOptions { /** * Callback to handle validation results. Receives all rules found per resolve cycle. * Defaults to `console.warn` for each rule. */ onReport?: (rules: HeadValidationRule[]) => void /** Configure severity and per-rule options. */ rules?: RulesConfig /** * Project root path. When set, source locations are displayed as relative paths (e.g., ./src/components/MyPage.vue:42:5). */ root?: string } ``` :: ## Rules ### URL Validity Google recommends [absolute canonical URLs](https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls#rel-canonical-link-method), and the [Open Graph URL type](https://ogp.me/#types) is limited to `http://` and `https://` resources. | Rule ID | What it catches | | --------- | ---------------- | | `non-absolute-canonical` | Canonical URL is not absolute (`/page` instead of `https://example.com/page`) | | `non-absolute-og-url` | `og:image`, `og:url`, `og:video`, `og:audio`, `twitter:image`, etc. are not absolute URLs | | `canonical-og-url-mismatch` | `` href differs from `og:url` content | ### Content Quality | Rule ID | What it catches | | --------- | ---------------- | | `missing-title` | Page has no `