Skip to main content

Introduction

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

Resolution priority

The head data for a page is resolved through the following five layers, from lowest to highest priority.
  1. Page defaults
  2. Route group metadata
  3. Route metadata
  4. Runtime metadata
  5. Error page metadata
Higher layers overwrite lower ones on a per-field basis. For example, a runtime title replaces a route title, but not its description.

Registering defaults

Register site-wide defaults in a service provider.
The defaults layer is the lowest-priority page layer. Unless a higher layer sets a title, Acme is used verbatim; when a higher layer sets a title, the inherited suffix is applied (Head::title('About') becomes About - Acme).

Route metadata

Static pages can attach metadata directly to their route definitions.
You can also apply metadata common to a whole group.
withHead() stores plain arrays through Laravel’s standard route metadata API (under the head key of ->metadata()), so it remains compatible with cached routes.

Runtime metadata

Values that aren’t known until the request arrives — like a post title — are set at runtime via the Head facade.
Conditional metadata is expressed fluently with when() / unless().

Error pages

You can also register metadata for each status code.
When a registered error status is rendered, this metadata takes precedence over every other layer.

Open Graph and Twitter Card

Set Open Graph properties with og() and add images, videos, or audio with methods like ogImage().
The document title and description automatically fill in an unset og:title and og:description. Twitter Card renders automatically from the same title, description, and image as Open Graph as long as you register it in your defaults.
You can also explicitly override the Twitter values on individual pages.

PWA, performance, and icons

The pwa() helper sets the <head> tags you need for an installable web app in one call.

Theme color

Theme color can be set globally, per route, or at runtime. Use the Media enum to specify per-media theme colors.
Media also includes Portrait and Landscape.

App metadata and icons

Laravel Head includes helpers for common browser and app metadata.
favicon() is an alias for icon() and accepts the same type, sizes, and media arguments.

Performance and discoverability

Laravel Head can also render performance hints, pagination links, locale alternates, and feed discovery tags.
preloadAsset() / prefetchAsset() resolve the URL with the asset() helper and detect the as attribute from the extension.

Custom tags

Tags without a dedicated method can be added with meta() / link().
meta() uses name= for ordinary meta tags, but automatically switches for keys that should use property=, such as Open Graph (og:) or article metadata (article:).

Structured data (JSON-LD)

The built-in schema builder covers the major JSON-LD types.
The built-in factory methods are article, blogPosting, product, offer, brand, breadcrumbs, faq, organization, person, webPage, and webSite. Unknown factory methods fall back to a generic schema object, so you can represent custom schema.org types too. Breadcrumb items can be added one at a time or in bulk. Positions are assigned automatically in insertion order.
FAQ questions follow the same pattern. Use question() for one, or questions() for many.
Custom schema types can be registered explicitly.

Wrap-up

laravel/head centralizes the metadata you need for SEO and social sharing across Blade, Livewire, and Inertia. Its five-layer structure — defaults, route, runtime, and error pages — keeps site-wide consistency while still allowing flexible per-page customization.

laravel/head repository

Source code and the latest updates.
Last modified on August 9, 2026