New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

crumby/canonical-hreflang

Automatic canonical and hreflang output for Laravel 5.4
38
Install
composer require crumby/canonical-hreflang
Latest Version:1.0.0
PHP:>=5.6.0
License:MIT License
Last Updated:Sep 24, 2017
Links: GitHub  ·  Packagist
Maintainer: crumby

Installation:

> 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 !!} 
    
    

Documentation:

API documentation

Related Packages

salamwaddah/laravel-canonical

:package_description

3,981 3
watson/canonical

Canonical host middleware for Laravel

360 3
escuccim/sitemap

a sitemap generator and admin for laravel

63 0
pushery/polyslug-for-laravel

Polymorphic, multilingual routable identity for Eloquent — leak-safe IDs, per-lo...

9,100 6
fkrzski/laravel-canonical

Laravel package for managing canonical URLs and preventing duplicate content

1,466 2

Version History

Version Released PHP License
1.0.0 >=5.6.0 MIT License