- What is laravel/head and what problem does it solve?
- Laravel Head is a first-party Laravel package that provides a fluent PHP API for building your application's document head: titles, meta tags, Open Graph data, canonical URLs, robots directives, performance hints, and JSON-LD structured data. It replaces scattered Blade stacks, inline meta literals, and per-view @section calls with one declarative, testable source of truth. Because it renders consistently across Blade, Livewire, and Inertia, mixed-paradigm apps avoid duplicated or divergent head markup.
- How do I install laravel/head in a Laravel application?
- Install it with composer require laravel/head. Then define application-wide defaults such as site name, default Open Graph image, Twitter card type, and canonical base, and set per-route or per-view values from controllers, middleware, or view components. Full setup and configuration details are in the official Laravel documentation at laravel.com/docs/head.
- Does laravel/head work with Livewire and Inertia?
- Yes. The package is designed to render head content consistently across Blade, Livewire, and Inertia views. That multi-renderer support is its main differentiator over single-paradigm SEO packages. It matters most if your app mixes server-rendered marketing pages with an Inertia SPA shell or uses Livewire navigation.
- Which Laravel versions does laravel/head support?
- Laravel Head is a first-party package maintained alongside the framework, and the README points to the official Laravel documentation for current requirements. Support for a given Laravel version is declared in the package's composer.json constraints, so check those before upgrading the framework. Because the package is pre-1.0 (currently 0.2.x), pinning versions and reviewing changelogs is advisable.
- Is laravel/head stable enough for production use?
- It is architecturally low-risk: it is additive, does not touch routing, persistence, or the domain layer, and can be adopted incrementally. The main risk is API stability, not quality. At 0.2.x with modest community adoption, minor releases may still introduce churn, so pin the version, review release notes, and keep head rendering covered by tests.
- Can I use laravel/head alongside an existing SEO package or Blade stacks?
- Technically yes, but validate precedence and deduplication carefully before shipping. Duplicate or conflicting canonical tags and Open Graph tags are real SEO defects, not cosmetic issues. If you already use Blade stacks, Inertia's Head component, or a third-party SEO package, migrate a small subset of routes first and inspect the rendered output for duplicates.
- How does laravel/head handle structured data and JSON-LD?
- It supports JSON-LD structured data, and the 0.2.2 release added a typed Event schema builder contributed by martinbean. That means common event markup no longer needs hand-written arrays, though other schema types may still require custom JSON-LD. Typed builders improve schema correctness, but they also mean schema shape becomes partly owned by the package rather than your templates, so schema changes track dependency upgrades.
- Is it safe to put user-generated meta content through laravel/head?
- Any API that emits CMS- or user-authored text into meta tags or JSON-LD needs correct escaping. Confirm that JSON-LD is produced through a script-safe encoder rather than raw string interpolation, since a stored XSS via metadata is a credible threat. The Event schema builder widens this surface because event names, locations, and descriptions are typically free text flowing into a script tag.
- How do I test head output generated by laravel/head?
- Because head is built through a fluent PHP API rather than embedded markup, you can assert against it in feature tests like any other application state. Render a route or component and assert the expected title, canonical, robots, and JSON-LD values appear exactly once. Testing for absence of duplicates is as important as testing for presence when other head mechanisms are still active.
- What alternatives exist to laravel/head and when should I choose them?
- Common alternatives include artesaos/seotools, ralphjsmit/laravel-seo, spatie/schema-org for JSON-LD, and built-in mechanisms like Blade stacks and Inertia's Head component. Laravel Head is most compelling when you want a single first-party API spanning Blade, Livewire, and Inertia. If you already have working head management on a single renderer and no cross-paradigm duplication problem, the benefit is smaller.