Ultimate SEO creation for Laravel 5

v0.0.5 2016-07-10 04:08 UTC

This package is not auto-updated.

Last update: 2024-11-19 22:54:08 UTC


README

Build Status Quality Score Latest Stable Version Total Downloads License

Pyncil SEO is the ultimate SEO generator for Laravel 5

Install

Via Composer

$ composer require pyncil/seo

###Update the Laravel Framework

Add the following provider to config/app.php

'providers' => [
    Pyncil\SEO\Providers\SEOServiceProvider::class
]

Usage

When creating a new view in your controller, you can set the SEO data:

public function showArticle(Request $request, $id)
{
    $article = Article::find($id);
    
    SEO::setTitle($article->title)
        ->setDescription($article->description)
        ->setCanonical()
        ->setNext(url('article/' . ($id + 1)))
        ->setPrev(url('article/' . ($id - 1)))
        ->setRobots();
    
    return view('article.show')->with('article', $article);
}

Note: Don't forget to add use SEO; to include the class.

Then, in your view, you can either get all of the tags:

<html>
    <head>
        <!-- Minified -->
        {!! SEO::get() !!}
        
        <!-- Unminified -->
        {!! SEO::get(false) !!}
    </head>
    <body>
        <!-- Page Content -->
    </body>
</html>

Or get each tag by hand:

<html>
    <head>
        {!! SEO::getTitle() !!}
        {!! SEO::getDescription() !!}
        {!! SEO::getCanonical() !!}
    </head>
    <body>
        <!-- Page Content -->
    </body>
</html>

See the available functions for a list of available getters and setters.

Functions

Setters:

Getters:

All of the following functions return html.

Custom Tags

Adding custom tags is a cinch! Simply declare the name and content like so:

Favicons

Many different browsers, computers, and operating systems like to retrieve a page's favicon in their own, creative ways. Stupid, I know. But, nevertheless, we must dance like the monkeys we are. So instead of creating 50 different favicons and link tags, just head on over to the Real Favicon Generator and download all of your new favicons.

Then, put them all in the folder of your choice.

DO NOT RENAME FILES

Once you do that, you can declare that you want favicons by calling:

SEO::favicons()->set('folder/containing/icons');

Note: the url you pass must be relative to the public directory.

then we can get your link tags dynamically like this:

<head>
    {!! SEO::favicons()->get() !!}
</head>

And that's it!

The generator will only generate tags corresponding with existing files. If you don't want the tag, don't include the file. Note: other items CAN exist in the icons folder. It is reccommended to put the icons in the /public directory.

Advanced Setup

Let's say you want to customize the icon sizes on Android or iPhone. Or maybe the tile color in Windows 8 or 10. The following functions allow you to make those custom changes:

These sizes each take an array variable. Each string in the array must be in format "144x144" and corresponds with a file by that size.

To set custom colors, use setColors($colors). It takes an array of colors in this format:

$colors = [
    'safari_pinned' => '#000000',
    'ms_tile' => '#000000',
    'theme' => '#000000'
];

those three color names are the only colors you may set. Colors must be in hex and none of them are required.

Credits

License

The MIT License (MIT). Please see License File for more information.