Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Head Laravel Package

laravel/head

Laravel Head offers a fluent API for managing your app's document head—titles, meta tags, Open Graph, canonical URLs, robots directives, performance hints, and structured data. Works with Blade, Livewire, and Inertia.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Release delta (v0.2.2). One change: a first-class Event schema builder for JSON-LD structured data (PR #13, external contributor martinbean). No breaking changes, no deprecations, no configuration or API surface removed. This is an additive feature that narrows the "generic JSON-LD only" gap flagged in the prior assessment — the package now ships at least one opinionated, typed schema helper rather than leaving all structured data to hand-rolled arrays. It does not answer any of the open integration questions below, and it does not change the architectural verdict. The version number remains 0.2.x, which reinforces the pre-1.0 churn expectation.

Architecture fit. Laravel Head is a first-party (laravel/head) presentation-layer utility that centralizes document <head> construction behind a fluent API: title, meta, Open Graph, canonical, robots directives, performance hints (preload/prefetch), and JSON-LD structured data. Architecturally this is a low-coupling, additive package — it does not touch routing, persistence, or the domain layer, so it slots into an existing Laravel app without reshaping boundaries. The value proposition is consolidation: replacing ad-hoc @section('title'), @stack('meta'), and per-view <meta> literals with a single declarative source of truth that is testable and consistent across Blade, Livewire, and Inertia entry points. The v0.2.2 Event schema helper slightly deepens the coupling to the package: typed schema builders mean schema shape is now partly owned by laravel/head rather than by our own view code. That is a net positive for correctness and consistency, but it means schema markup changes become a dependency-upgrade concern, not purely a template concern.

Integration feasibility. Straightforward for a standard Laravel app: composer require laravel/head, define application-wide defaults (site name, default OG image, Twitter card type, canonical base), then set per-route/per-view values in controllers, middleware, or view components. The multi-renderer support (Blade, Livewire, Inertia) is the main differentiator versus single-paradigm alternatives, and it matters if the app mixes server-rendered marketing pages with an Inertia SPA shell. The new Event schema builder is directly usable if the product has any date-bearing content (webinars, launches, ticketing, scheduled releases) — it removes a small but real chunk of hand-written JSON-LD. If there is no event-like content in scope, the release is inert for us and can be taken at the next routine bump.

Technical risk.

  • Youth and thin adoption signal. 123 stars and 0 dependents indicate negligible third-party production exposure. First-party ownership mitigates quality risk but not API-stability risk; pre-1.0-style churn is plausible in the first few minor releases, and v0.2.2 confirms the project is still in active feature-add mode rather than stabilization mode.
  • Overlap with existing mechanisms. Most Laravel apps already have some head management — Blade stacks, Inertia's <Head> component, Livewire's @push/navigate hooks, or a third-party SEO package (artesaos/seotools, ralphjsmit/laravel-seo, spatie/schema-org for JSON-LD). Precedence and deduplication behavior when both systems emit tags is the single most important thing to validate; duplicated or conflicting canonicals/OG tags are an SEO defect, not a cosmetic one.
  • Escaping and injection. Any API that accepts free-text meta content and emits JSON-LD must escape correctly. Confirm JSON-LD is emitted via a script-safe encoder rather than raw string interpolation; a stored XSS via CMS-authored metadata is a credible threat vector. The new Event builder widens this surface modestly — event fields (name, location, description, performer names) are typically CMS- or user-authored strings, and each is a new value that flows into a <script type="application/ld+json"> block.
  • Schema correctness vs. schema presence. A typed builder makes it easy to emit schema that is structurally valid but semantically wrong or incomplete for Google's rich-result requirements (e.g. missing startDate timezone offsets, missing location or offers). Emitting a malformed Event schema is worse than emitting none: it can trigger Search Console errors and suppress rich results. Validation must be an explicit test step, not an assumption inherited from the library.
  • Client-side navigation. With wire:navigate or Inertia visits, head state must update on soft navigations, not just full page loads. Failure here manifests as stale titles/canonicals for crawlers that execute JS and for users.
  • Caching interaction. Full-page or response caching can freeze head output; per-user or per-locale metadata (hreflang, canonical, and now event dates/availability) must be part of the cache key or resolved after cache retrieval.

Key questions.

  1. What is the supported Laravel/PHP version matrix, and what is the project's stated backwards-compatibility policy?
  2. How does it reconcile with Inertia's built-in <Head> component and Livewire's wire:navigate — does it own head state end-to-end, or defer?
  3. What are the override semantics for nested components (parent layout default vs. child override vs. merge for arrays like OG images or JSON-LD graphs)?
  4. Does it deduplicate tags and define deterministic ordering, and can we assert output in feature tests — including asserting the emitted Event schema against the schema.org/Google rich-results shape?
  5. Is JSON-LD encoding delegated to a vetted encoder, and is there a documented escaping contract for event fields sourced from user or CMS input?
  6. Is the schema API extensible beyond the built-in Event type — can we register custom types (Article, Product, FAQPage, BreadcrumbList) without dropping to raw HTML, or is schema-org still needed alongside?
  7. Does it handle hreflang/alternate links and pagination rel links, or is that out of scope?
  8. Are there extension points for custom tags (e.g., analytics, verification meta) without dropping to raw HTML?

Integration Approach

Stack fit. Best fit: Laravel 11/12 applications rendering through Blade or Livewire, with or without an Inertia front end. It is most valuable where multiple rendering paradigms coexist and head logic has already drifted. Weakest fit: SPAs where the front end owns the document head entirely, or legacy apps with a deeply entrenched SEO package whose admin UI is business-critical — the migration cost outweighs the benefit there. v0.2.2 marginally widens the fit: if the roadmap includes event-style content, the built-in builder is an argument for laravel/head over a general schema package for that slice. If structured data is broad and heterogeneous (products, reviews, FAQs, breadcrumbs), a dedicated schema library is still likely to sit alongside rather than be replaced.

Migration path. Treat this as a strangler-style consolidation, not a big-bang rewrite:

  1. Add the package and configure defaults in a service provider (site name, canonical base, default OG image, robots default).
  2. Convert the root layout(s) only — title and canonical first, the two tags with the highest SEO blast radius.
  3. Move per-route metadata into controllers or a small metadata resolver, keeping values sourced from the same place as today (config, DB, CMS) to avoid content drift.
  4. Port Open Graph/Twitter tags next, then robots directives, then JSON-LD.
  5. Use the built-in Event builder only where an event actually exists in the domain and the data already lives in a model or CMS — do not synthesize events to fill the feature. Validate every emitted schema with an external validator (Rich Results Test) once during the spike and pin the result in a snapshot test.
  6. Remove the legacy @section/@stack head blocks only after output parity is confirmed by tests.

Compatibility. Verify against the actual pinned Laravel and PHP versions before committing. Check for coexistence with any existing SEO package — running both in parallel deliberately during migration is acceptable only if one is configured to emit nothing. Validate Inertia SSR if used: head tags must appear in the server-rendered HTML, not only after hydration, or crawlers and social scrapers see nothing. Treat v0.2.2 as a safe minor bump from v0.2.1 (additive, no removals) provided our own snapshot tests still pass — the risk is not regression in existing output but the temptation to adopt the new schema helper mid-migration.

Sequencing. Package evaluation spike (1–2 days) → output-parity test harness comparing legacy and new head markup for a representative page set → layout conversion → route-by-route conversion by traffic tier → structured-data conversion (legacy JSON-LD and/or new Event builder) → legacy removal. Gate the whole effort on the spike answering the precedence and escaping questions; if those are unresolved, do not proceed to layout conversion. Adopting the Event schema explicitly is a separate, lower-priority decision that should follow layout conversion, not lead it — schema is invisible to users and carries no rendering risk, but it does carry search-result risk if wrong.

Operational Impact

Maintenance. Low ongoing cost. MIT license, first-party stewardship, changelog and tagged releases present, and the surface area is small — it emits markup and holds no state. Budget for periodic version bumps aligned to Laravel major releases, plus review of head output whenever templates change. One new maintenance obligation from v0.2.2: if the Event builder is adopted, event markup becomes dependency-owned, so schema shape changes on upgrade. Keep a snapshot test of emitted schema so a version bump that alters field names or ordering surfaces as a failing test rather than a silent Search Console warning.

Support. Documentation lives on the Laravel website, and support flows through the repository and Laravel's community channels — no commercial SLA unless covered by a Laravel support arrangement. Given 0 dependents, expect to be an early adopter: issues you hit may be unreported. That argues for pinning a known-good version and maintaining an internal note of deviations. The Event contributor is external, so coverage of edge cases (multi-day events, online-only events, timezone handling) should be treated as unproven until we test the specific shapes our content uses.

Scaling. Runtime cost is negligible — string assembly and rendering, no I/O. The scaling concerns are indirect: head resolution added to a hot render path should stay allocation-light, and if metadata is fetched from a database or CMS per request, that lookup belongs behind the existing cache layer rather than being introduced as a newly-per-request query. Event schema built from model data is one more argument for precomputing and caching the serialized schema blob alongside the page rather than assembling it per request.

Failure modes.

  • Silent duplication or omission of canonical/OG tags → degraded search and social previews, invisible in functional tests. Mitigate with snapshot assertions on head output.
  • Invalid or incomplete Event schema → Search Console errors and lost rich-result eligibility. Mitigate with a schema snapshot plus one-time external validation during the spike.
  • Stale head under soft navigation → wrong titles in browser history, analytics page titles, and JS-executing crawlers.
  • Frozen head under response caching → wrong canonical/hreflang per locale or tenant, and stale event dates/availability. Include metadata inputs in cache keys.
  • Escaping defect in JSON-LD or meta content → XSS from CMS-authored or user-supplied event fields.
  • Render-path exception → a metadata error taking down page rendering. Wrap head construction so failures degrade to a minimal safe head rather than a 500; apply the same guard around schema construction, which now has more input validation surface.
  • API churn on upgrade → broken layouts or changed schema output after a minor bump. Pin versions and upgrade deliberately with the parity test suite as the gate.

Ramp-up. Low for anyone already fluent in Laravel — the fluent API is idiomatic and the README-to-first-tag path is short. The real learning curve is organizational: agreeing a single metadata source of truth, defining defaults, and assigning ownership. v0.2.2 adds a small, contained technical learning item — whoever writes structured data must understand the Event schema's required fields and validation, which is a content-modeling skill rather than a Laravel skill. Estimate half a day per engineer for the API plus a short internal convention doc covering override rules and JSON-LD authoring standards, with a one-page addendum on event schema fields and the validation step.

Recommendation. Adopt conditionally — unchanged in direction, marginally strengthened in case. The package is a sensible consolidation of a genuinely messy cross-cutting concern and carries first-party credibility, but the adoption signal (123 stars, 0 dependents) means the risk is unproven behavior at the edges — precedence, soft navigation, escaping — not code quality. v0.2.2 is a benign, additive release that does not alter the decision and should not accelerate it; it is not a reason to bring structured-data work forward ahead of layout conversion. Run the short spike that answers the precedence, soft-navigation, and escaping questions with real markup diffs; proceed to migration only if it does. Track the schema API separately: if laravel/head grows typed builders for the schema types we actually need, it becomes a genuine replacement for a standalone schema package — until then, assume coexistence.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo