laravel-seo maintained by sabuj073
Description
Laravel SEO package for per-page meta tags, Open Graph and Twitter Card
Author
Last update
2026/03/10 06:03
(dev-main)
License
Downloads
0
Tags
Laravel SEO
Per-page SEO meta tags for Laravel: title, description, image, canonical, Open Graph and Twitter Card.
Installation
composer require sabuj073/laravel-seo
php artisan vendor:publish --tag=seo-config
# optional views
php artisan vendor:publish --tag=seo-views
Configuration
In .env:
SEO_DEFAULT_TITLE="My Site"
SEO_DEFAULT_DESCRIPTION="Default meta description"
SEO_DEFAULT_IMAGE="https://yoursite.com/og-default.jpg"
SEO_TITLE_SEPARATOR=" | "
Usage
In controllers or middleware, set SEO for the current page:
use Sabuj073\Seo\Seo;
public function show(Post $post, Seo $seo)
{
$seo->title($post->title)
->description(Str::limit($post->excerpt, 160))
->image($post->featured_image_url)
->canonical(route('posts.show', $post))
->keywords($post->tags->pluck('name')->toArray())
->ogType('article');
return view('posts.show', compact('post'));
}
In your main layout (e.g. resources/views/layouts/app.blade.php), inside <head>:
{!! app(\Sabuj073\Seo\Seo::class)->render() !!}
Or register a facade in config/app.php:
'aliases' => [
'Seo' => \Sabuj073\Seo\SeoFacade::class,
],
Then in layout:
{!! Seo::render() !!}
Chaining:
Seo::title('Contact')
->description('Get in touch with us')
->canonical(route('contact'));
Default title is appended with SEO_TITLE_SEPARATOR and SEO_DEFAULT_TITLE when you set a page title.