A Laravel-native package to manage SEO-related HTML tags with precision and developer experience in mind.
Supports title, meta, og:*, twitter:*, and canonical tags — nothing more, nothing less.
- Fluent, expressive API via a
Seofacade - Supports standard SEO, Open Graph, and Twitter tags
- Automatically renders tags via the
@seoBlade directive - Enum-based tag validation for strict SEO compliance
- Default fallback values via
config/seo.php - Auto-injects
<link rel="canonical">(optional)
composer require fabpl/laravel-seoPublish the config file:
php artisan vendor:publish --tag=seo-configEdit the config/seo.php file to set global defaults:
return [
/*
|--------------------------------------------------------------------------
| Default Title
|--------------------------------------------------------------------------
|
| This title will be used if no title is explicitly set via Seo::title().
|
*/
'title' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Default Meta Tags
|--------------------------------------------------------------------------
|
| Meta tags that should be included by default on all pages.
| Only tags defined in MetaTags enum are supported.
|
*/
'meta' => [
'author' => '',
'description' => '',
'keywords' => '',
'robots' => 'index, follow',
],
/*
|--------------------------------------------------------------------------
| Default Open Graph Tags
|--------------------------------------------------------------------------
|
| Open Graph tags included on all pages. Keys must match values from
| the OpenGraphTags enum.
|
*/
'open_graph' => [
'og:description' => '',
'og:image' => '',
'og:locale' => env('APP_LOCALE', 'en'),
'og:site_name' => env('APP_NAME', 'Laravel'),
'og:title' => env('APP_NAME', 'Laravel'),
'og:type' => 'website',
],
/*
|--------------------------------------------------------------------------
| Default Twitter Tags
|--------------------------------------------------------------------------
|
| Twitter card tags included by default. Keys must match values from
| the TwitterTags enum.
|
*/
'twitter' => [
'twitter:card' => 'summary_large_image',
'twitter:creator' => '', // e.g. '@username'
'twitter:description' => '',
'twitter:image' => '',
'twitter:site' => '', // e.g. '@yourhandle'
'twitter:title' => env('APP_NAME', 'Laravel'),
],
/*
|--------------------------------------------------------------------------
| Auto Canonical URL
|--------------------------------------------------------------------------
|
| When enabled, the current URL will be automatically added as a canonical
| tag unless manually overridden via Seo::canonical().
|
*/
'auto_canonical' => true,
];use Fabpl\Seo\Facades\Seo;
use Fabpl\Seo\Enums\MetaTags;
use Fabpl\Seo\Enums\OpenGraphTags;
use Fabpl\Seo\Enums\TwitterTags;
Seo::title('Laravel Seo Package')
->description('A Laravel-native package to manage SEO-related HTML tags with precision and developer experience in mind.')
->twitter(TwitterTags::Creator, '@fabpl')
->canonical('https://github.com/fabpl/laravel-seo');<head>
...
@seo
</head>Only officially supported SEO tags are allowed. All supported keys are defined as PHP enum classes:
Fabpl\Seo\Enums\MetaTagsFabpl\Seo\Enums\OpenGraphTagsFabpl\Seo\Enums\TwitterTags
Invalid keys throw exception.
Seo::title(string $title): self;
Seo::description(string $description): self;
Seo::keywords(array $keywords): self;
Seo::author(string $author): self;
Seo::canonical(string $url): self;
Seo::meta(MetaTags $name, string $content): self;
Seo::openGraph(OpenGraphTags $name, string $content): self;
Seo::twitter(TwitterTags $name, string $content): self;
Seo::render(): HtmlString;
Tests are included and can be run with:
composer testMIT © Fabrice