Seo Helper

SeoHelper

Class: App\Services\Frontend\SeoHelper

Constructs SEO layout parameters (title, description, ogImage, ogType, etc.) for frontend pages. Used by base Livewire components and available for direct use.

Access

In base Livewire components:

$this->seo()->forPost($post);

Directly:

$seo = app(SeoHelper::class);

Methods

forPost(Post $post): array

Returns SEO params for a blog post with ogType=article. Uses excerpt for description, falls back to content.

forPage(Post $page): array

Returns SEO params for a static page. Includes _toolbarPost for admin toolbar.

forTerm(Term $term, string $taxonomy): array

Returns SEO params for a taxonomy archive. Tag titles get a # prefix.

forSearch(string $query): array

Returns SEO params for search results. Shows Search: {query} or just Search.

forBlogListing(?Post $blogPage = null): array

Returns SEO params for blog listing. Uses blog page title/excerpt if available.

forHomepage(?Post $page = null): array

Returns SEO params for homepage. Uses page data if configured.

forCustom(string $title, string $description, array $extra): array

Build arbitrary SEO params with custom values.

mergeDefaults(array $params): array

Appends - {app.name} to title (if not already present). Fires FrontendFilterHook::SEO_PARAMS filter.

SEO Head Blade Partial

Use @include('components.seo-head') in your layout to render all SEO meta tags:

<head>
    @include('components.seo-head')
</head>

This renders: title, description, keywords, author, canonical URL, Open Graph tags, Twitter Card tags, and JSON-LD structured data.

Output Keys

Key Type Description
title string Page title with app name suffix
description string Meta description (max 160 chars)
ogType string Open Graph type (default: website)
ogImage string Open Graph image URL
_toolbarPost ?Post Context post for admin toolbar
/