laravel-seo-meta-box maintained by gabrieliuga
Description
Add SEO capabilities to your website
Author
Last update
2021/06/30 17:10
(dev-master)
License
Downloads
29
Tags
Add seo capabilities to your Laravel application
Adds ability to create custom titles / description on a per page basis. Includes usage of Twitter handles and Open Graph data for social sharing.
Installation
You can install the package via composer:
composer require gabrieliuga/laravel-seo-meta-box
Usage
artisan migrate
artisan vendor:publish --tag=metabox-config
/**
* Manual entry
*/
Seo::create([
'slug' => '/', //this is the page route
'title' => 'Super special application',
'description' => 'My super special application that does x',
'type' => 'page'
]);
/**
* Model based generator
*/
use Giuga\LaravelSeoMetaBox\Traits\HasSeo;
use Giuga\LaravelSeoMetaBox\Traits\SeoOptions;
use Illuminate\Database\Eloquent\Model;
class Page extends Model
{
use HasSeo;
public function getSeoOptions(): SeoOptions
{
return SeoOptions::create()
->setSlugField('slug') // optional
->setRoutePrefix('/page/') // optional
->setTitleField('name') // optional
->setDescriptionField('short_description') // optional
->setOverwriteOnUpdate(); // optional
}
}
Change your application layout to include @metabox blade component
<head>
@metabox
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet">
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
The output will be (with all options enabled)
<title>Super special application - Application Name</title>
<meta name="description" content="My super special application that does x"/>
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@g_iuga">
<meta name="twitter:title" content="Super special application - Application Name">
<meta name="twitter:description" content="My super special application that does x">
<meta name="twitter:creator" content="@g_iuga">
<meta property="og:title" content="Super special application - Application Name" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://example.com" />
<meta property="og:description" content="My super special application that does x" />
<meta property="og:site_name" content="Application Name" />
Testing
phpunit
View Customise
If you want to customize the output in any way, you can do so by publishing the view:
artisan vendor:publish --tag=metabox-views
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email me@iuga.dev instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.