agpretto / metadata
Metadata package for Laravel applications
Requires
- php: ^7.1
- illuminate/console: ^5.0|^6.0
- illuminate/view: ^5.0|^6.0
Requires (Dev)
- phpunit/phpunit: ^7.5|^8.0
This package is auto-updated.
Last update: 2024-10-29 06:05:40 UTC
README
This package provides a way to include metadata tags and other SEO related values inside a view.
This is the most flexible way of inject metadata inside webpages without the need of a database.
Use this package if you don't need complex implementation over SEO metadata.
Configuration
Composer
Require this package inside your composer.json file
"agpretto/metadata": "^0.1"
Install
Use the package install command to install Metadata inside your application.
php artisan metadata:install // or php artisan metadata:install --template
Opt-in publishing the default metadata template to your
resouces/views/vendor/metadata
folder.
You can opt-in publishing metadata template by using the flag -T
or --template
.
Usage
This package is a very simple metadata management suite to include metadata tags and related SEO values inside a view.
-
Before start using this package update the configuration file
config/metadata.php
with your default SEO informations. -
Include a new stack inside your base layout view. This stack will collect all your SEO metadata.
// main layout <!DOCTYPE html> <html> <head> <!-- Metadata --> @stack('metadata') </head> <body> </body> </html>
Now you're ready to include your metadata.
- Choose a public view of your website content (ex. views/articles/page.blade.php).
@extends('layouts.page') @section('content') <section> <h2>{{ $article->title }}</h2> <div>{{ $article->body }}</div> </section> @endsection // push metadata view on the stack @push('metadata') @include('metadata::metadata', [ 'title' => $article->title, // <- use the model title to contextualize the title metadata 'author' => 'John Doe' // <- or simply overrides default author value at runtime ]) @endpush
Credits
This package is built for you by the Interstellar Developer Andrea Giuseppe - Github