├── LICENSE.txt ├── README.md ├── composer.json └── src ├── Facades └── Seo.php ├── Seo.php ├── SeoServiceProvider.php └── views ├── meta-facebook.blade.php ├── meta-twitter.blade.php ├── sd-breadcrumblist.blade.php ├── sd-local-business.blade.php ├── sd-organization.blade.php └── sd-website.blade.php /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # laravel-seo 2 | SEO tools to insert meta and structured-data in laravel projects 3 | 4 | ## Installation and setup 5 | 6 | ```bash 7 | composer require helori/laravel-seo:dev-master 8 | ``` 9 | 10 | Configure your application: 11 | ```php 12 | // config/app.php 13 | 'providers' => [ 14 | ... 15 | Helori\LaravelSeo\SeoServiceProvider::class, 16 | ]; 17 | 'aliases' => [ 18 | ... 19 | 'Seo' => Helori\LaravelSeo\Facades\Seo::class, 20 | ]; 21 | ``` 22 | 23 | Publish the views if you wish to overwite the defaults: 24 | ```bash 25 | php artisan vendor:publish --provider="Helori\LaravelSeo\SeoServiceProvider" --tag="views" 26 | ``` 27 | 28 | ## How to use 29 | 30 | In your layout, include theses views as needed: 31 | ```html 32 | 33 | @include('laravel-seo::meta-facebook') 34 | @include('laravel-seo::meta-twitter') 35 | 36 | 37 | @include('laravel-seo::sd-organization') 38 | @include('laravel-seo::sd-local-business') 39 | @include('laravel-seo::sd-website') 40 | @include('laravel-seo::sd-breadcrumblist') 41 | 42 | ``` 43 | You can also include SEO information directly without using built-in views : 44 | ```html 45 | 46 | ``` 47 | 48 | Add SEO information from your controller using the SEO facade. For example : 49 | ```php 50 | // --------------------------------------------------------------------- 51 | // SEO data shared between views : 52 | // --------------------------------------------------------------------- 53 | public function __construct(){ 54 | Seo::set('global-title', 'Website name'); 55 | Seo::set('global-description', 'Website description'); 56 | 57 | Seo::set('logo-url', 'logo url'); 58 | Seo::set('search-url', 'search url for structured data'); 59 | Seo::set('latitude', 48.8256); 60 | Seo::set('longitude', 2.3258); 61 | 62 | Seo::set('email', 'organization email'); 63 | Seo::set('phone', 'organization phone'); 64 | Seo::set('opening-hours', 'Mo,Tu,We,Th,Fr 09:00-20:00'); 65 | Seo::set('street-address', '1, welcome street'); 66 | Seo::set('address-locality', 'Paris'); 67 | Seo::set('address-region', ''); 68 | Seo::set('address-country', 'FR'); 69 | Seo::set('postal-code', '75008'); 70 | Seo::set('area-served', 'FR'); 71 | 72 | Seo::setSimilarTo('https://www.facebook.com/my-facebook-page'); 73 | Seo::setSimilarTo('https://twitter.com/my-twitter-page'); 74 | 75 | Seo::setContactPoint([ 76 | 'type' => 'customer-service', 77 | 'phone' => 'phone number', 78 | 'area-served' => 'FR', 79 | 'opening-hours' => 'Mo,Tu,We,Th,Fr 09:00-20:00', 80 | 'available-languages' => ['French'] 81 | ]); 82 | 83 | Seo::set('og-locale', 'fr_FR'); 84 | Seo::set('og-image-url', 'facebook_image_url'); 85 | Seo::set('og-image-type', 'image/jpeg'); 86 | Seo::set('og-image-width', 1200); 87 | Seo::set('og-image-height', 630); 88 | 89 | Seo::set('fb-app-id', 'My facebook app ID'); 90 | Seo::set('twitter-sign', '@My_Twitter_Account'); 91 | } 92 | 93 | // --------------------------------------------------------------------- 94 | // Page specific SEO data : 95 | // --------------------------------------------------------------------- 96 | public function home(){ 97 | Seo::set('title', 'My home page title'); 98 | Seo::set('description', "My home page description"); 99 | Seo::set('keywords', "my,home,page,keywords"); 100 | Seo::set('breadcrumblist', [ 101 | ['title' => 'Page short title', 'url' => 'page_url'], 102 | ['title' => 'Sub-Page short title', 'url' => 'sub_page_url'], 103 | ]); 104 | } 105 | ``` 106 | 107 | 108 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "helori/laravel-seo", 3 | "description": "SEO tools to insert meta and structured-data in laravel projects", 4 | "keywords": ["laravel", "seo", "structured data"], 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Helori Lanos", 9 | "email": "helori@algoart.fr", 10 | "homepage": "https://algoart.fr" 11 | } 12 | ], 13 | "repositories": [ 14 | { 15 | "type": "git", 16 | "url": "https://github.com/helori/laravel-seo.git" 17 | } 18 | ], 19 | "autoload": { 20 | "psr-4": { 21 | "Helori\\LaravelSeo\\": "src/" 22 | } 23 | }, 24 | "require": { 25 | "php": ">=5.5.9" 26 | }, 27 | "require-dev": { 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Facades/Seo.php: -------------------------------------------------------------------------------- 1 | data[$key] = $value; 26 | }else{ 27 | return isset($this->data[$key]) ? $this->data[$key] : ''; 28 | } 29 | } 30 | 31 | public function has($key) 32 | { 33 | return isset($this->data[$key]); 34 | } 35 | 36 | public function get($key) 37 | { 38 | return isset($this->data[$key]) ? $this->data[$key] : ''; 39 | } 40 | 41 | public function set($key, $value) 42 | { 43 | $this->data[$key] = $value; 44 | } 45 | 46 | public function setSimilarTo($value) 47 | { 48 | $this->similarTo[] = $value; 49 | } 50 | 51 | public function similarTo() 52 | { 53 | return $this->similarTo; 54 | } 55 | 56 | public function setContactPoint(array $value) 57 | { 58 | $this->contactPoints[] = $value; 59 | } 60 | 61 | public function contactPoints() 62 | { 63 | return $this->contactPoints; 64 | } 65 | } -------------------------------------------------------------------------------- /src/SeoServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->bind('seo', 'Helori\LaravelSeo\Seo'); 12 | } 13 | 14 | public function boot() 15 | { 16 | $this->loadViewsFrom(__DIR__.'/views', 'laravel-seo'); 17 | 18 | $this->publishes([ 19 | __DIR__.'/views' => base_path('resources/views/vendor/laravel-seo'), 20 | ], 'views'); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/views/meta-facebook.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | @if(Seo::get('fb-app-id')) 9 | 10 | @endif 11 | 12 | 32 | 33 | @if($mime && $w && $h) 34 | 35 | 36 | 37 | 38 | @endif -------------------------------------------------------------------------------- /src/views/meta-twitter.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/views/sd-breadcrumblist.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | @if(is_array(Seo::get('breadcrumblist'))) 5 | 23 | @endif -------------------------------------------------------------------------------- /src/views/sd-local-business.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 67 | -------------------------------------------------------------------------------- /src/views/sd-organization.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 35 | -------------------------------------------------------------------------------- /src/views/sd-website.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | --------------------------------------------------------------------------------