Skip to main content

Introduction

laravel/head is an official Laravel package that provides a fluent API for managing your application’s document <head>. It supports title and meta tags, Open Graph, canonical URLs, robots directives, performance hints, and structured data, and works across Blade, Livewire, and Inertia. v0.1.0 was released on July 28, 2026.

Resolution Precedence

Page head data resolves from five layers, listed from lowest to highest priority:
  1. Page defaults
  2. Route group metadata
  3. Route metadata
  4. Runtime metadata
  5. Error metadata
Higher layers replace lower layers field by field. For example, a runtime title replaces the route title without replacing the route description.

Defaults

Register page defaults in a service provider:
The defaults layer is the lowest-priority page layer. If no higher layer sets a title, Acme renders as-is. When a higher layer sets a title, the inherited suffix is applied — Head::title('About') renders About - Acme. Pass exact: true for titles that should ignore the inherited prefix or suffix. Canonical URLs use the current request URL. Pass a string for an explicit URL: Head::canonical('/about'). URLs are normalized to https by default; pass forceHttps: false to preserve the request scheme.

Route Metadata

Static pages can define metadata directly on the route:
Shared metadata can be applied to a group:
Resource and singleton routes are supported too:
withHead() stores plain arrays through Laravel’s native route metadata API, keeping it compatible with cached routes.

Supported Properties

Runtime Metadata

For values that aren’t known until a request arrives — such as a post title — set them at runtime via the Head facade:
Multiple runtime calls are merged in order. For single-value fields, the later call wins. Repeatable fields keep multiple entries but updating the same key replaces the earlier entry. Conditional metadata can be defined fluently with when() and unless():

Error Pages

Register metadata for specific HTTP status codes:
When a response is rendered for a registered error status, that metadata beats every other layer.

Open Graph and Twitter Cards

Set Open Graph properties with og(), and add repeatable media with dedicated methods:
The document title and description automatically fill missing og:title and og:description values. For a single OG image with no other attributes, use the image: shorthand on og():
Twitter Cards are registered in defaults and automatically render from the same title, description, and image used by Open Graph:
Individual pages may override Twitter values explicitly:

Theme Colors and App Metadata

Theme colors can be set globally, per route, or at runtime. Media-specific colors are supported via the Media enum:
Laravel Head includes helpers for common browser and app metadata:

Progressive Web Apps

The pwa() helper configures the common <head> tags needed for an installable web app:
This renders the application name, web app manifest link, theme color, iOS standalone metadata, and the Apple touch icon in one call.

Performance and Discovery

Laravel Head renders performance hints, pagination links, locale alternates, and feed discovery:
For local assets, preloadAsset() and prefetchAsset() resolve the URL through asset() and detect the as attribute from the file extension. Font preloads automatically include crossorigin:

Custom Tags

For tags without a dedicated method, use meta() and link():
meta() uses name= for regular meta tags. For keys that normally use property= such as Open Graph (og:) or article metadata (article:), it switches automatically:

Structured Data (JSON-LD)

Built-in schema builders cover common JSON-LD types:
Built-in factory methods include article, blogPosting, product, offer, brand, breadcrumbs, faq, organization, person, webPage, and webSite. Unknown factory methods fall back to a generic schema object. Breadcrumb items may be added one at a time or in bulk — positions are assigned automatically:

Summary

laravel/head provides a unified, fluent API for managing <head> metadata across Blade, Livewire, and Inertia. Its five-layer resolution model — defaults, route group, route, runtime, and error — keeps site-wide consistency while allowing per-page flexibility, without scattering <meta> tags across templates.

laravel/head repository

Source code and latest updates.
Last modified on July 29, 2026