All Projects β†’ eusonlito β†’ Laravel Meta

eusonlito / Laravel Meta

Licence: mit
HTML Meta Tags management package available for for Laravel 5.*

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Laravel Meta

Seo Helper
πŸ” SEO Helper is a package that provides tools and helpers for SEO (Search Engine Optimization).
Stars: ✭ 262 (+74.67%)
Mutual labels:  meta, laravel, tags
Nova Tags Field
A tags field to use in your Nova apps
Stars: ✭ 204 (+36%)
Mutual labels:  laravel, tags
phoenix meta tags
Phoenix library helps generating meta tags for website.
Stars: ✭ 25 (-83.33%)
Mutual labels:  meta, tags
Laravelmetatags
The most powerful and extendable tools for managing SEO Meta Tags in your Laravel project
Stars: ✭ 226 (+50.67%)
Mutual labels:  meta, laravel
Tags
A Tagging package that easily allows you to add tags to your Eloquent models.
Stars: ✭ 134 (-10.67%)
Mutual labels:  laravel, tags
audio-tag-analyzer
Extracts metadata music metadata found in audio files
Stars: ✭ 18 (-88%)
Mutual labels:  meta, tags
Seo Manager
Seo Manager Package for Laravel ( with Localization )
Stars: ✭ 192 (+28%)
Mutual labels:  meta, laravel
Laravel Tags
Add tags and taggable behaviour to your Laravel app
Stars: ✭ 1,026 (+584%)
Mutual labels:  laravel, tags
Open Graph
Library that assists in building Open Graph meta tags
Stars: ✭ 112 (-25.33%)
Mutual labels:  laravel, tags
Craft Seomatic
SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.
Stars: ✭ 135 (-10%)
Mutual labels:  meta, tags
Discord
Discord notification channel for Laravel
Stars: ✭ 148 (-1.33%)
Mutual labels:  laravel
Apiserver
基于Laravelηš„APIζœεŠ‘η«―ζžΆζž„δ»£η 
Stars: ✭ 148 (-1.33%)
Mutual labels:  laravel
Laravel Video
A laravel package to stream video content.
Stars: ✭ 150 (+0%)
Mutual labels:  laravel
Credit Card
Credit Card Validation
Stars: ✭ 150 (+0%)
Mutual labels:  laravel
Servermonitor
πŸ’“ Laravel package to periodically monitor the health of your server and application.
Stars: ✭ 148 (-1.33%)
Mutual labels:  laravel
Phpspec Laravel
Test your Laravel applications with phpspec
Stars: ✭ 149 (-0.67%)
Mutual labels:  laravel
Laravel Model Expires
A package to assign expiration dates to Eloquent models.
Stars: ✭ 148 (-1.33%)
Mutual labels:  laravel
Google Places Api
This is a PHP wrapper for Google Places API Web Service. And is Laravel Framework friendly.
Stars: ✭ 147 (-2%)
Mutual labels:  laravel
Messager
A convenient way to handle messages between users in a simple way
Stars: ✭ 147 (-2%)
Mutual labels:  laravel
Larecipe
πŸͺ Write gorgeous documentation for your products using Markdown inside your Laravel app.
Stars: ✭ 1,953 (+1202%)
Mutual labels:  laravel

HTML Meta Tags management package available for Laravel 5/6/7/8

Build Status Latest Stable Version Total Downloads License

With this package you can manage header Meta Tags from Laravel controllers.

If you want a Laravel <= 4.2 compatible version, please use v4.2 branch.

Installation

Begin by installing this package through Composer.

{
    "require": {
        "eusonlito/laravel-meta": "3.1.*"
    }
}

Laravel installation

// config/app.php

'providers' => [
    '...',
    Eusonlito\LaravelMeta\MetaServiceProvider::class
];

'aliases' => [
    '...',
    'Meta'    => Eusonlito\LaravelMeta\Facade::class,
];

Now you have a Meta facade available.

Publish the config file:

php artisan vendor:publish --provider="Eusonlito\LaravelMeta\MetaServiceProvider"

app/Http/Controllers/Controller.php

<?php namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;

use Meta;

abstract class Controller extends BaseController
{
    use DispatchesCommands, ValidatesRequests;

    public function __construct()
    {
        # Default title
        Meta::title('This is default page title to complete section title');

        # Default robots
        Meta::set('robots', 'index,follow');

        # Default image
        Meta::set('image', asset('images/logo.png'));
    }
}

app/Http/Controllers/HomeController.php

<?php namespace App\Http\Controllers;

use Meta;

class HomeController extends Controller
{
    public function index()
    {
        # Section description
        Meta::set('title', 'You are at home');
        Meta::set('description', 'This is my home. Enjoy!');
        Meta::set('image', asset('images/home-logo.png'));

        return view('index');
    }

    public function detail()
    {
        # Section description
        Meta::set('title', 'This is a detail page');
        Meta::set('description', 'All about this detail page');

        # Remove previous images
        Meta::remove('image');

        # Add only this last image
        Meta::set('image', asset('images/detail-logo.png'));

        # Canonical URL
        Meta::set('canonical', 'http://example.com');

        return view('detail');
    }

    public function private()
    {
        # Section description
        Meta::set('title', 'Private Area');
        Meta::set('description', 'You shall not pass!');
        Meta::set('image', asset('images/locked-logo.png'));

        # Custom robots for this section
        Meta::set('robots', 'noindex,nofollow');

        return view('private');
    }
}

resources/views/html.php

<html>
    <head>
        <meta charset="utf-8" />
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />

        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta name="author" content="Lito - [email protected]" />

        <title>{!! Meta::get('title') !!}</title>

        {!! Meta::tag('robots') !!}

        {!! Meta::tag('site_name', 'My site') !!}
        {!! Meta::tag('url', Request::url()); !!}
        {!! Meta::tag('locale', 'en_EN') !!}

        {!! Meta::tag('title') !!}
        {!! Meta::tag('description') !!}

        {!! Meta::tag('canonical') !!}

        {{-- Print custom section images and a default image after that --}}
        {!! Meta::tag('image', asset('images/default-logo.png')) !!}
    </head>

    <body>
        ...
    </body>
</html>

Or you can use Blade directives:

<html>
    <head>
        <meta charset="utf-8" />
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />

        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta name="author" content="Lito - [email protected]" />

        <title>{!! Meta::get('title') !!}</title>

        @meta('robots')

        @meta('site_name', 'My site')
        @meta('url', Request::url())
        @meta('locale', 'en_EN')

        @meta('title')
        @meta('description')

        @meta('canonical')

        {{-- Print custom section images and a default image after that --}}
        @meta('image', asset('images/default-logo.png'))

        {{-- Or use @metas to get all tags at once --}}
        @metas
        
    </head>

    <body>
        ...
    </body>
</html>

Config

return [
    /*
    |--------------------------------------------------------------------------
    | Limit title meta tag length
    |--------------------------------------------------------------------------
    |
    | To best SEO implementation, limit tags.
    |
    */

    'title_limit' => 70,

    /*
    |--------------------------------------------------------------------------
    | Limit description meta tag length
    |--------------------------------------------------------------------------
    |
    | To best SEO implementation, limit tags.
    |
    */

    'description_limit' => 200,

    /*
    |--------------------------------------------------------------------------
    | Limit image meta tag quantity
    |--------------------------------------------------------------------------
    |
    | To best SEO implementation, limit tags.
    |
    */

    'image_limit' => 5,

    /*
    |--------------------------------------------------------------------------
    | Available Tag formats
    |--------------------------------------------------------------------------
    |
    | A list of tags formats to print with each definition
    |
    */

    'tags' => ['Tag', 'MetaName', 'MetaProperty', 'TwitterCard'],
];

Using Meta outside Laravel

Controller

require __DIR__.'/vendor/autoload.php';

// Check default settings
$config = require __DIR__.'/src/config/config.php';

$Meta = new Eusonlito\LaravelMeta\Meta($config);

# Default title
$Meta->title('This is default page title to complete section title');

# Default robots
$Meta->set('robots', 'index,follow');

# Section description
$Meta->set('title', 'This is a detail page');
$Meta->set('description', 'All about this detail page');
$Meta->set('image', '/images/detail-logo.png');

# Canonical URL
$Meta->set('canonical', 'http://example.com');

Template

<title><?= $Meta->get('title'); ?></title>

<?= $Meta->tag('robots'); ?>

<?= $Meta->tag('site_name', 'My site'); ?>
<?= $Meta->tag('url', getenv('REQUEST_URI')); ?>
<?= $Meta->tag('locale', 'en_EN'); ?>

<?= $Meta->tag('title'); ?>
<?= $Meta->tag('description'); ?>

<?= $Meta->tag('canonical'); ?>

# Print custom section image and a default image after that
<?= $Meta->tag('image', '/images/default-logo.png'); ?>

Updates from 2.*

  • Meta::meta('title', 'Section Title') > Meta::set('title', 'Section Title')
  • Meta::meta('title') > Meta::get('title')
  • Meta::tagMetaName('title') > Meta::tag('title')
  • Meta::tagMetaProperty('title') > Meta::tag('title')
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].