m2collective / laravel-metadata-markup
A package for adding and editing meta tags on a website.
Package info
github.com/m2collective/laravel-metadata-markup
pkg:composer/m2collective/laravel-metadata-markup
Requires
- php: ^8.3
- laravel/framework: ^13.0
This package is not auto-updated.
Last update: 2026-07-31 06:23:33 UTC
README
A package for adding and editing meta tags on a website.
Installation
You can install the package via composer:
composer require m2collective/laravel-metadata-markup
The package will automatically register itself.
Commands
Publishing the configuration file:
php artisan m2collective:metadata-markup:publish-config
Publishing HTML views:
php artisan m2collective:metadata-markup:publish-views
Usage
After installing the package, you can add and edit meta tags on your website.
Dependency injection
An example of using a package with the dependency injection:
use M2Collective\MetadataMarkup\MetadataMarkup; final class Example { /** * @var MetadataMarkup */ protected MetadataMarkup $markup; /** * @param MetadataMarkup $markup */ public function __construct( MetadataMarkup $markup ) { $this->markup = $markup; } /** * @return array */ public function markup(): array { // Editing service variables. $this->markup ->viewport('width=device-width, initial-scale=1') ->charset('utf-8') ->title('Document title') ->description('Document description') ->keywords('Document keywords') ->robots('index, follow') ->author('M2Collective') ->copyright('M2Collective') ->canonical('https://example.com/') ->prev(null) ->next(null) // Passing variables from the service. return [ 'viewport' => $markup->viewport->getContent(), 'charset' => $markup->charset->getContent(), 'title' => $markup->title->getContent(), 'description' => $markup->description->getContent(), 'keywords' => $markup->keywords->getContent(), 'robots' => $markup->robots->getContent(), 'author' => $markup->author->getContent(), 'copyright' => $markup->copyright->getContent(), 'canonical' => $markup->canonical->getHref(), 'prev' => $markup->prev->getHref(), 'next' => $markup->next->getHref(), ]; } }
Facades
An example of using a package with the facades:
use M2Collective\MetadataMarkup\Facades\MetadataMarkup; final class Example { /** * @return array */ public function markup(): array { // Editing service variables. $markup = MetadataMarkup::viewport('width=device-width, initial-scale=1') ->charset('utf-8') ->title('Document title') ->description('Document description') ->keywords('Document keywords') ->robots('index, follow') ->author('M2Collective') ->copyright('M2Collective') ->canonical('https://example.com/') ->prev(null) ->next(null) // Passing variables from the service. return [ 'viewport' => $markup->viewport->getContent(), 'charset' => $markup->charset->getContent(), 'title' => $markup->title->getContent(), 'description' => $markup->description->getContent(), 'keywords' => $markup->keywords->getContent(), 'robots' => $markup->robots->getContent(), 'author' => $markup->author->getContent(), 'copyright' => $markup->copyright->getContent(), 'canonical' => $markup->canonical->getHref(), 'prev' => $markup->prev->getHref(), 'next' => $markup->next->getHref(), ]; } }
Blade
An example of using a package with the blade:
<!DOCTYPE html> <html lang="en"> <head> <x-metadata-markup::viewport/> <x-metadata-markup::charset/> <x-metadata-markup::title/> <x-metadata-markup::description/> <x-metadata-markup::keywords/> <x-metadata-markup::robots/> <x-metadata-markup::author/> <x-metadata-markup::copyright/> <x-metadata-markup::canonical/> <x-metadata-markup::prev/> <x-metadata-markup::next/> </head> <body> </body> </html>
License
The MIT License (MIT). Please see the License file for more information.