davmixcool / laravel-meta-manager
Laravel Meta Manager is an SEO tool that is used to improve SEO of a website or specific page by adding recommended meta tags to your application.
Package info
github.com/davmixcool/laravel-meta-manager
pkg:composer/davmixcool/laravel-meta-manager
Fund package maintenance!
Requires
- php: ^8.1
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
- illuminate/view: ^10.0|^11.0|^12.0|^13.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0|^11.0
- phpunit/phpunit: ^10.0|^11.0|^12.0
README
Laravel Meta Manager is an SEO tool that is used to improve the SEO of a website or specific page by adding recommended meta tags to your application.
SEO Features
- Standard Meta Tags
- Facebook OpenGraph Meta Tags
- Twitter Card Meta Tags
- Dublin Core Meta Tags
- Link Tags
- Canonical URLs
- Social image dimensions and alt text
Requirements
- PHP 8.1 and above
- Laravel 10, 11, 12 or 13
Laravel 13 requires PHP 8.3 and above.
Laravel 10 and 11 have reached end of life. This package still supports them and still tests against them, so an existing application can upgrade. Note that Composer now refuses to install those Laravel versions into a new project, because every release in both lines carries an unpatched security advisory.
On Laravel 9 or below? You get v1, and that is the correct outcome. composer require davmixcool/laravel-meta-manager resolves to 1.2 on its own, because v2 requires Laravel 10+ — this is
tested on Laravel 5.5 through 9. If your application already requires ^1.0, composer update keeps
you there too. v1 is supported for security fixes and its documentation is on the
1.x branch.
Upgrading from v1? Nothing in your application needs to change. See UPGRADE.md.
Steps:
Install
Composer
Run the following to include this package via Composer
composer require davmixcool/laravel-meta-manager
Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
Once the download is complete, the next thing you have to do is include the service provider within config/app.php.
'providers' => [ Davmixcool\MetaManager\MetaServiceProvider::class, ];
Then run;php artisan vendor:publish --provider="Davmixcool\MetaManager\MetaServiceProvider" to get the config of Laravel Meta Manager.
Configuration
Setup default application meta inmeta.phpconfig. (Optional but recommended)
Available options:
| Option | Description |
|---|---|
robots |
Robots option tells search engines what to follow and what not to follow. |
revisit_after |
Here you may specify how search engines will re-visit and re-crawl your site. |
referrer |
Here you may specify how you want other sites to get referrer information from your site. |
type |
Here you may specify the structure type of your website or a specific page |
title |
Here you may provide the title of your website or a specific page to help search engines understand it better. |
description |
Here you may provide the description of your website or a specific page to help search engines understand it better. |
image |
Here you may provide the URL to the image you want search engines and crawlers to make use of when displaying your website or a specific page. |
author |
Here you may provide the author's name you want search engines to make use of when displaying your website or a specific page. |
geo_region |
Here you specify the region of your location. This is useful if you have a physical location that is important for your business. |
geo_position |
Here you specify the geo-coordinates of your physical location in longitude and latitude. |
twitter_site |
Here you may provide your Twitter @username of your account |
twitter_card |
Here you may specify the way you want crawlers to understand your Twitter share type. |
fb_app_id |
Here you may provide your Facebook app id |
keywords |
Here you may provide keywords relevant to your website and the specific page. |
site_name |
Here you may provide the name of your site. Defaults to your application name. |
locale |
Here you may provide the locale of your content, such as en_US. Defaults to your application locale. |
title_template |
Here you may provide a template applied to titles you set, such as %s — Acme. |
canonical |
Here you may provide the canonical URL of your page, or current to use the current URL. |
twitter_creator |
Here you may provide the Twitter @username of the content author. |
image_width |
Here you may provide the width of your image so crawlers can lay out the preview before it loads. |
image_height |
Here you may provide the height of your image so crawlers can lay out the preview before it loads. |
image_alt |
Here you may provide the alternative text describing your image. |
blade_tags |
Here you may specify which tags @include('meta::manager') prints, either extended or standard. |
geo_placename |
Here you specify the place name of your location, such as a city. Leave empty to use your application name, or set it to false to leave the tag out. |
dcterms_subject |
Here you may specify the Dublin Core subject of your content, which is not always the same as your keywords. Leave empty to reuse your keywords, or set it to false to leave the tag out. |
Usage
Once the configuration is complete you can then add the below at the meta area of the page you want to include meta tags;
@include('meta::manager')
The above will use the predefined configurations to prefill the generated meta tags. However, if you chose to define certain options on the fly then you can use the code below.
@include('meta::manager', [ 'title' => 'My Example Title', 'description' => 'This is my example description', 'image' => 'Url to the image', ])
The available options are title, description, keywords, author, image, type, robots, referrer, twitter_card and twitter_site.
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
@include('meta::manager', [
'title' => 'My Example Title',
'description' => 'This is my example description',
'image' => '',
])
</head>
<body>
</body>
</html>
Fluent API
If you would rather set your meta from a controller than pass it through the view, you can. Both work together, and options passed to @include still take precedence.
use Davmixcool\MetaManager\Facades\Meta; Meta::title('My Example Title') ->description('This is my example description') ->image(asset('og.png'), width: 1200, height: 630, alt: 'My Example Title');
Your layout keeps using @include('meta::manager'), or you can render the tags directly;
{!! Meta::render() !!}
Available methods:
| Method | Description |
|---|---|
title |
Here you may provide the title of the page. Also fills the OpenGraph and Twitter titles. |
description |
Here you may provide the description of the page. Also fills the OpenGraph and Twitter descriptions. |
image |
Here you may provide the image, along with its width, height and alt text. |
canonical |
Here you may provide the canonical URL of the page. |
robots |
Here you may specify what search engines should follow. index(), noIndex(), follow() and noFollow() are also available. |
type |
Here you may specify the structure type of the page. |
siteName |
Here you may provide the name of your site. |
locale |
Here you may provide the locale of your content. |
keywords |
Here you may provide keywords relevant to the page, as a string or an array. |
author |
Here you may provide the author's name. |
add |
Here you may add any other meta tag by name. |
property |
Here you may add any other meta tag by property. |
link |
Here you may add any link tag. favicon() is also available. |
openGraph |
Here you may override the OpenGraph tags individually. |
twitter |
Here you may override the Twitter card tags individually. |
toArray |
Here you may inspect the generated meta, which is useful in tests. |
validate |
Here you may check your meta for common problems. |
You can also check your meta from the command line;
php artisan meta:check
Stargazers
Thank you to everyone who has starred this package.
Forkers
And to everyone who has forked it.
Maintainers
This package is maintained by David Oti and you!
License
This package is licensed under the MIT license.