SEO
Kompass ships a fluent SeoService for managing <title>, <meta>, and Open Graph / Twitter tags across your application. You reach it from anywhere through the global seo() helper.
Looking for custom model data?
To store arbitrary key-value data on a model, see the Metadata feature and its HasMeta trait.
The seo() Helper
Call seo() in a controller, Livewire component, or page view to build up the tags fluently. This is exactly how the default page view (page.blade.php) sets them:
@php
$webtitle = setting('global.webtitle', 'Kompass');
seo()
->title(($page->title ?? $webtitle) . ' | ' . $webtitle)
->description($page->meta_description ?? setting('global.description', ''))
->locale(str_replace('_', '-', app()->getLocale()))
->twitter();
if ($ogImage = setting('global.ogimage_src')) {
seo()->tag('og:image', asset($ogImage));
}
@endphpEach setter returns the service, so calls chain. Values set later in the request win, which lets a layout define defaults that individual pages override.
Methods
| Method | Description |
|---|---|
title($title, $default = null, $modify = null) | Sets the page title. |
description($string) | Sets the meta description. |
keywords($string) | Sets meta keywords. |
locale($string) | Sets the content locale (e.g. de_DE). |
site($string) | Sets the site name. |
url($string) | Sets the canonical / Open Graph URL. |
image($url) | Sets the Open Graph image. |
type($string) | Sets the Open Graph type (default website). |
twitter() | Enables Twitter card tags using the site handle from settings. |
tag($key, $value) | Sets a custom meta tag. |
setFromArray($data) | Sets many tags at once from an array. |
reset() | Clears all tags set so far. |
Setting Tags in Blade
Use the @seo directive to set tags directly from a Blade view — it forwards the array to setFromArray():
@seo([
'title' => $page->title,
'description' => $page->getMeta('description'),
'image' => asset('storage/' . $page->hero_image),
])Rendering in Layouts
You don't render tags one by one. Drop the seo-meta component into your layout's <head> and it outputs everything you've set — <title>, the meta description, Open Graph tags, the canonical link, and Twitter card tags (when twitter() was called):
<head>
<x-kompass::seo-meta />
{{-- your other head tags --}}
</head>Already wired up
The default Kompass layout (layouts/main.blade.php) already includes <x-kompass::seo-meta /> in its <head>. If you use it, just set tags with seo() in your page — rendering is handled for you.
Reading values back
Need a raw value in your own markup? Use seo()->get('title'), seo()->tags() for custom tags, or seo()->isTwitterEnabled() — the same accessors the seo-meta component uses internally.