fomvasss/laravel-seo
Laravel SEO package
Support
If this package is useful to you, consider supporting its development:
USDT TRC20 address:
THLgp6DxiAtbNHvgnKV56vk1L38UuUagKf
With this package you can manage meta-tags and SEO-fields from Laravel app.
Installation
You can install the package via composer:
composer require fomvasss/laravel-seo
You can publish and run the migrations with:
php artisan vendor:publish --provider="Fomvasss\Seo\SeoServiceProvider"
php artisan migrate
Usage
The Eloquent model must has the Trait HasSeo:
namespace App\Models;
use Fomvasss\Seo\Models\HasSeo;
class PostModel extends Model {
use HasSeo;
//...
public function registerSeoDefaultTags(): array
{
return [
'title' => $this->name,
'description' => $this->description,
'og_image' => $this->getFirstMediaUrl('images', 'thumb'),
];
}
}
Also in model you can define default tags in method registerSeoDefaultTags
Allowed next methods (By increasing priority):
Seo::setDefault(['title' => 'Blog']);
Seo::setModel($post);
Seo::setPath('page/faq');
Seo::setTags(['keywords' => 'Laravel, SEO, tags']);
Rendering tags in Blade (in HTML head):
{!!
\Seo::setGroup(app()->getLocale())
->setDefault([
'og_site_name' => config('app.name'),
'og_url' => URL::full(),
'og_locale' => app()->getLocale(),
])->renderHtml()
!!}
Get array tags (for API resource, etc.):
\Seo::setGroup(app()->getLocale())
->setDefault([
'og_site_name' => config('app.name'),
'og_locale' => app()->getLocale(),
])->getTags();
You can save tags for model in DB:
$post->seo('uk')->updateOrCreate([], ['tags' => ['title' => 'Hello Page', 'description' => 'Lorem Ipsum'], 'group' => 'uk']);
And get tags (for edit) for dashboard:
$tags = $post->getRawSeoTags('uk');
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
Related Packages
Analyze keywords in the content and make diagnostics to improve the seo score of...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 1.13.0 | ^8.0 | ^9| | MIT | |
| 1.12.0 | ^8.0 | ^9| | MIT | |
| 1.11.0 | ^8.0 | ^9| | MIT | |
| 1.10.0 | ^8.0 | ^9| | MIT | |
| 1.9.0 | ^8.0 | ^9| | MIT | |
| 1.8.0 | ^8.0 | ^9| | MIT | |
| 1.7.0 | ^8.0 | ^9| | MIT | |
| 1.6.0 | ^8.0 | ^9| | MIT | |
| 1.5.0 | ^8.0 | ^9| | MIT | |
| 1.4.0 | ^8.0 | ^9| | MIT | |
| 1.3.0 | ^8.0 | ^9.0 | MIT | |
| 1.2.0 | ^8.0 | ^9.0 | MIT | |
| 1.1.0 | ^8.0 | ^9.0 | MIT | |
| 1.0.1 | ^8.0 | ^9.0 | MIT | |
| 1.0.0 | ^8.0 | ^9.0 | MIT |