Skip to content

VictoRD11/laravel-meta-tags

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Meta

Build Status Latest Stable Version Total Downloads License

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

Installation

Begin by installing this package through Composer.

{
    "require": {
        "laravel/meta": "master-dev"
    }
}

Laravel installation

// app/config/app.php

'providers' => [
    '...',
    'Laravel\Meta\MetaServiceProvider',
];

When you've added the MetaServiceProvider an extra Meta facade is available. You can use this Facade anywhere in your application

Publish the config file:

php artisan config:publish laravel/meta

app/controllers/homeController.php

class Home extends Controller {
    public function index()
    {
        Meta::title('This is default page title to complete section title');

        Meta::meta('title', 'You are at home');
        Meta::meta('description', 'This is my home. Enjoy!');
        Meta::meta('image', 'images/facebook.php');
        Meta::meta('image', 'images/twitter.php');
        Meta::meta('image', 'images/linkedin.php');

        return View::make('html')->nest('body', 'index');
    }
}

app/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::meta('title'); ?></title>

        <meta property="og:site_name" content="My site" />
        <meta property="og:url" content="<?= Request::url(); ?>" />
        <meta property="og:locale" content="en_EN" />

        <?= Meta::tag('title'); ?>
        <?= Meta::tag('description'); ?>
        <?= Meta::tag('image'); ?>
    </head>

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

About

Meta Tags management to Laravel

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 66.4%
  • CSS 29.9%
  • PHP 3.7%