crumby / canonical-hreflang
Automatic canonical and hreflang output for Laravel 5.4
1.0.0
2017-08-21 06:19 UTC
Requires
- php: >=5.6.0
- crumby/route-locale: 1.0.*@dev
This package is not auto-updated.
Last update: 2024-11-10 04:32:48 UTC
README
> composer require crumby/canonical-hreflang
> php artisan vendor:publish --provider="Crumby\CanonicalHreflang\CanonicalHreflangServiceProvider" --tag=config
Register service and facade:
File: config/app.php
'providers' => [
......................
'Crumby\CanonicalHreflang\CanonicalHreflangServiceProvider',
........................
];
'aliases' => [
......................
'Canonicalhreflang' => 'Crumby\CanonicalHreflang\Facades\CanonicalHreflang',
......................
];
Register global middlewear:
file app/Http/Kernel.php
protected $middleware = [
.............................
\Crumby\CanonicalHreflang\Middleware\CanonicalHreflangMiddleware::class
];
Configuration:
Besides automatically set canonical url links to head, it also sets Hreflang, if unabled. config/canonical-hreflang.php
'multilangular' => true
Example:
-
add middleware to constructor of your controller
class StaticPagesController extends Controller { public function __construct() { ........................... $this->middleware('CanonicalHreflang'); ........................... } }
-
place this variable to your Blade template head section
{!! $CanonicalHreflang !!}