With this package you can manage header Meta Tags from Laravel controllers.
Begin by installing this package through Composer.
{
"require": {
"laravel/meta": "master-dev"
}
}
// 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
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');
}
}
<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>