SEO

SEO

Generate meta tags with quick and easy functions & blade directives.

Moamen Eltouny (Raggi)
PHP Version : >= 7.2 Laravel Version : >= 6.0 License Support
Source Packagist Version Packagist Downloads

Install

Install the latest version using Composer

composer require pharaonic/laravel-seo
Charset

Setting from Controller

seo()->setCharset('UTF-8');

Setting from View (Blade)

@charset('UTF-8')
Title

Setting from Controller

seo()->setTitle('Pharaonic');

Setting from View (Blade)

@title('Pharaonic')
Description

Setting from Controller

seo()->setDescription('Pharaonic site contains a variety of packages ...');

Setting from View (Blade)

@description('Pharaonic site contains a variety of packages ...')
Keywords

Accepts (string, array)

Setting from Controller

seo()->setKeywords(['word1', 'word2', 'word3']);

Setting from View (Blade)

@keywords('word1, word2, word3')
Author

Setting from Controller

seo()->setAuthor('Moamen Eltouny');

Setting from View (Blade)

@author('Moamen Eltouny')
Copyrights

Setting from Controller

seo()->setCopyrights('Pharaonic');

Setting from View (Blade)

@copyrights('Pharaonic')
Robots

Setting from Controller

seo()->setRobots('index,nofollow');

Setting from View (Blade)

@robots('index,nofollow')
Canonical

Setting from Controller

seo()->setCanonical('https://pharaonic.io');

Setting from View (Blade)

@canonical('https://pharaonic.io')
Languages

Setting from Controller

seo()->setAlternate('ar', 'https://pharaonic.io/ar/package/2-laravel/15-seo');
seo()->setAlternate('en.US', 'https://pharaonic.io/en/package/2-laravel/15-seo');

Setting from View (Blade)

@alternate('ar', 'https://pharaonic.io/ar/package/2-laravel/15-seo')
@alternate('en.US', 'https://pharaonic.io/en/package/2-laravel/15-seo')
Images

Setting from Controller

seo()->setImage('https://pharaonic.io/images/logo.jpg');

Setting from View (Blade)

@image('https://pharaonic.io/images/logo.jpg');
Customized

Setting from Controller

// Meta
seo()->setMeta('viewport', 'width=device-width, initial-scale=1.0');

// Open-Graph
seo()->setOG('type', 'website');

// Twitter
seo()->setTwitter('card', 'summary');

Setting from View (Blade)

// Meta
@meta('viewport', 'width=device-width, initial-scale=1.0');

// Open-Graph
@og('type', 'website');

// Twitter
@twitter('card', 'summary');
From Model

Setting from Controller ONLY

1. You have to add toSEO method to your model and specify your columns.

/**
 * SEO Columns, Meta, Open-Graph and Twitter
 *
 * @return array
 */
public function toSEO()
{
    return [
        'columns'   => [    // Data from columns here
            'title'         => 'title',         // Name of title column here
            'description'   => 'description',   // Name of description column here
        ],

        'meta'      => [    // Customized data
            'theme-color'   => '#4285f4'
        ],

        'og'        => [    // Customized Open-Graph data
            'type'          => 'website'
        ],

        'twitter'   => [    // Customzied Twitter data
            'card'          => 'summary'
        ]
    ];
}

2. Calling SEO method to generate it from the Model. (Example)

$article = Article::first();
seo()->model($article);
Generating

Setting from View (Blade)

Default

@seoDefault

Result :




Pharaonic









Open-Graph

@seoOG

Result :








Twitter

@seoTwitter

Result :




ALL IN ONE

@seo

Result :




Pharaonic