A SEO package made for maximum customization and flexibility.
composer require romanzipp/laravel-seo
Or add romanzipp/laravel-seo
to your composer.json
"romanzipp/laravel-seo": "^1.0.0"
Run composer install
to pull the latest version.
If you use Laravel 5.5+ you are already done, otherwise continue:
Add Service Provider to your app.php
configuration file:
romanzipp\Seo\Providers\SeoServiceProvider::class,
Copy configuration to config folder:
$ php artisan vendor:publish --provider="romanzipp\Seo\Providers\SeoServiceProvider"
use romanzipp\Seo\Facades\Seo;
use romanzipp\Seo\Services\SeoService;
class IndexController
{
public function index(Request $request, SeoService $seo)
{
$seo = seo();
$seo = app(SeoService::class);
$seo = Seo::make();
}
}
use romanzipp\Seo\Structs\Title;
seo()->add(Title::make()->body('romanzipp'));
seo()->title('romanzipp');
... both compile to ...
<title>romanzipp</title>
use romanzipp\Seo\Structs\Meta\Charset;
seo()->add(new Charset);
use romanzipp\Seo\Structs\Meta\Charset;
seo()->add(Charset::make());
use romanzipp\Seo\Structs\Meta\Charset;
seo()->add(Charset::make()->charset('utf-8'));
... all compile to ...
<meta charset="utf-8" />
seo()->twitter('card', 'summary');
use romanzipp\Seo\Structs\Meta\Twitter;
seo()->add(Twitter::make()->name('card')->content('summary'));
... both compile to ...
<meta name="twitter:card" content="summary" />
seo()->twitter('site_name', 'romanzipp');
use romanzipp\Seo\Structs\Meta\OpenGraph;
seo()->add(OpenGraph::make()->name('site_name')->content('romanzipp'));
... both compile to ...
<meta name="og:site_name" content="romanzipp" />
For more information see the Structs Documentation.
{{ seo()->render() }}
This package features a basic integration for Spaties Schema.org package to generate ld+json scripts. Added Schema types render with the packages structs.
use Spatie\SchemaOrg\Schema;
seo()->addSchema(
Schema::localBusiness()->name('Spatie')
);
use Spatie\SchemaOrg\Schema;
seo()->setSchemes([
Schema::localBusiness()->name('Spatie'),
Schema::airline()->name('Spatie'),
]);
Take a look at the Schema.org package Docs.
Code | Rendered HTML |
---|---|
seo()->title('romanzipp') |
<title>romanzipp</title> |
seo()->meta('author', 'romanzipp') |
<meta name="author" content="romanzipp" /> |
seo()->twitter('card', 'summary') |
<meta name="twitter:card" content="summary" /> |
seo()->og('site_name', 'romanzipp') |
<meta name="og:site_name" content="romanzipp" /> |
seo()->add(Charset::make()->charset('utf-8')) |
<meta charset="utf-8" /> |
./vendor/bin/phpunit