{"id":16350396,"url":"https://github.com/eusonlito/laravel-meta","last_synced_at":"2025-05-16T12:11:39.591Z","repository":{"id":19678197,"uuid":"22932113","full_name":"eusonlito/laravel-Meta","owner":"eusonlito","description":"HTML Meta Tags management package available for for Laravel \u003e= 5 (Including 10)","archived":false,"fork":false,"pushed_at":"2024-06-17T14:19:38.000Z","size":330,"stargazers_count":195,"open_issues_count":1,"forks_count":77,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-31T22:09:32.545Z","etag":null,"topics":["html","laravel","meta","php","tags"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eusonlito.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-08-13T21:38:10.000Z","updated_at":"2025-03-27T20:51:33.000Z","dependencies_parsed_at":"2024-06-18T13:55:02.532Z","dependency_job_id":null,"html_url":"https://github.com/eusonlito/laravel-Meta","commit_stats":{"total_commits":81,"total_committers":7,"mean_commits":"11.571428571428571","dds":"0.12345679012345678","last_synced_commit":"2488fad353b9f2ba088d32c5aca6eee39897408c"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eusonlito%2Flaravel-Meta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eusonlito%2Flaravel-Meta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eusonlito%2Flaravel-Meta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eusonlito%2Flaravel-Meta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eusonlito","download_url":"https://codeload.github.com/eusonlito/laravel-Meta/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247994119,"owners_count":21030050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["html","laravel","meta","php","tags"],"created_at":"2024-10-11T01:04:48.690Z","updated_at":"2025-04-09T07:05:04.708Z","avatar_url":"https://github.com/eusonlito.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HTML Meta Tags management package available for Laravel \u003e= 5 (Including 10)\n\n[![Build Status](https://travis-ci.org/eusonlito/laravel-Meta.svg?branch=master)](https://travis-ci.org/eusonlito/laravel-Meta)\n[![Latest Stable Version](https://poser.pugx.org/eusonlito/laravel-meta/v/stable.png)](https://packagist.org/packages/eusonlito/laravel-meta)\n[![Total Downloads](https://poser.pugx.org/eusonlito/laravel-meta/downloads.png)](https://packagist.org/packages/eusonlito/laravel-meta)\n[![License](https://poser.pugx.org/eusonlito/laravel-meta/license.png)](https://packagist.org/packages/eusonlito/laravel-meta)\n\nWith this package you can manage header Meta Tags from Laravel controllers.\n\nIf you want a Laravel \u003c= 4.2 compatible version, please use `v4.2` branch.\n\n## Installation\n\nBegin by installing this package through Composer.\n\n```js\n{\n    \"require\": {\n        \"eusonlito/laravel-meta\": \"3.1.*\"\n    }\n}\n```\n\n### Laravel installation\n\n```php\n\n// config/app.php\n\n'providers' =\u003e [\n    '...',\n    Eusonlito\\LaravelMeta\\MetaServiceProvider::class\n];\n\n'aliases' =\u003e [\n    '...',\n    'Meta'    =\u003e Eusonlito\\LaravelMeta\\Facade::class,\n];\n```\n\nNow you have a ```Meta``` facade available.\n\nPublish the config file:\n\n```\nphp artisan vendor:publish --provider=\"Eusonlito\\LaravelMeta\\MetaServiceProvider\"\n```\n\n#### app/Http/Controllers/Controller.php\n\n```php\n\u003c?php namespace App\\Http\\Controllers;\n\nuse Illuminate\\Foundation\\Bus\\DispatchesCommands;\nuse Illuminate\\Routing\\Controller as BaseController;\nuse Illuminate\\Foundation\\Validation\\ValidatesRequests;\n\nuse Meta;\n\nabstract class Controller extends BaseController\n{\n    use DispatchesCommands, ValidatesRequests;\n\n    public function __construct()\n    {\n        # Default title\n        Meta::title('This is default page title to complete section title');\n\n        # Default robots\n        Meta::set('robots', 'index,follow');\n\n        # Default image\n        Meta::set('image', asset('images/logo.png'));\n    }\n}\n```\n\n#### app/Http/Controllers/HomeController.php\n\n```php\n\u003c?php namespace App\\Http\\Controllers;\n\nuse Meta;\n\nclass HomeController extends Controller\n{\n    public function index()\n    {\n        # Section description\n        Meta::set('title', 'You are at home');\n        Meta::set('description', 'This is my home. Enjoy!');\n        Meta::set('image', asset('images/home-logo.png'));\n\n        return view('index');\n    }\n\n    public function detail()\n    {\n        # Section description\n        Meta::set('title', 'This is a detail page');\n        Meta::set('description', 'All about this detail page');\n\n        # Remove previous images\n        Meta::remove('image');\n\n        # Add only this last image\n        Meta::set('image', asset('images/detail-logo.png'));\n\n        # Canonical URL\n        Meta::set('canonical', 'http://example.com');\n\n        return view('detail');\n    }\n\n    public function private()\n    {\n        # Section description\n        Meta::set('title', 'Private Area');\n        Meta::set('description', 'You shall not pass!');\n        Meta::set('image', asset('images/locked-logo.png'));\n\n        # Custom robots for this section\n        Meta::set('robots', 'noindex,nofollow');\n\n        return view('private');\n    }\n}\n```\n\n#### resources/views/html.php\n\n```php\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003cmeta charset=\"utf-8\" /\u003e\n        \u003cmeta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" /\u003e\n\n        \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /\u003e\n        \u003cmeta name=\"author\" content=\"Lito - lito@eordes.com\" /\u003e\n\n        \u003ctitle\u003e{!! Meta::get('title') !!}\u003c/title\u003e\n\n        {!! Meta::tag('robots') !!}\n\n        {!! Meta::tag('site_name', 'My site') !!}\n        {!! Meta::tag('url', Request::url()); !!}\n        {!! Meta::tag('locale', 'en_EN') !!}\n\n        {!! Meta::tag('title') !!}\n        {!! Meta::tag('description') !!}\n\n        {!! Meta::tag('canonical') !!}\n\n        {{-- Print custom section images and a default image after that --}}\n        {!! Meta::tag('image', asset('images/default-logo.png')) !!}\n    \u003c/head\u003e\n\n    \u003cbody\u003e\n        ...\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\nOr you can use Blade directives:\n\n```php\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003cmeta charset=\"utf-8\" /\u003e\n        \u003cmeta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" /\u003e\n\n        \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /\u003e\n        \u003cmeta name=\"author\" content=\"Lito - lito@eordes.com\" /\u003e\n\n        \u003ctitle\u003e{!! Meta::get('title') !!}\u003c/title\u003e\n\n        @meta('robots')\n\n        @meta('site_name', 'My site')\n        @meta('url', Request::url())\n        @meta('locale', 'en_EN')\n\n        @meta('title')\n        @meta('description')\n\n        @meta('canonical')\n\n        {{-- Print custom section images and a default image after that --}}\n        @meta('image', asset('images/default-logo.png'))\n\n        {{-- Or use @metas to get all tags at once --}}\n        @metas\n        \n    \u003c/head\u003e\n\n    \u003cbody\u003e\n        ...\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\n### MetaProduct / og:product\nThis will allow you to add product data to your meta data. See [Open Graph product object](https://developers.facebook.com/docs/payments/product/)\n```php\n// resources/views/html.php\n\n\u003chead\u003e\n    ...\n    {!! Meta::tag('type') !!} // this is needed for Meta Product to change the og:type to og:product\n    {!! Meta::tag('product') !!}\n\u003c/head\u003e\n\n```\n\nAdd your product data from your controller\n\n```php\n\u003c?php namespace App\\Http\\Controllers;\n\nuse Meta;\n\nclass ProductController extends Controller\n{\n    public function show()\n    {\n        # Add product meta\n        Meta::set('product', [\n            'price' =\u003e 100,\n            'currency' =\u003e 'EUR',\n        ]);\n        \n        # if multiple currencies just add more product metas\n        Meta::set('product', [\n            'price' =\u003e 100,\n            'currency' =\u003e 'USD',\n        ]);\n\n        return view('index');\n    }\n}\n```\n\n### Config\n\n```php\nreturn [\n    /*\n    |--------------------------------------------------------------------------\n    | Limit title meta tag length\n    |--------------------------------------------------------------------------\n    |\n    | To best SEO implementation, limit tags.\n    |\n    */\n\n    'title_limit' =\u003e 70,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Limit description meta tag length\n    |--------------------------------------------------------------------------\n    |\n    | To best SEO implementation, limit tags.\n    |\n    */\n\n    'description_limit' =\u003e 200,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Limit image meta tag quantity\n    |--------------------------------------------------------------------------\n    |\n    | To best SEO implementation, limit tags.\n    |\n    */\n\n    'image_limit' =\u003e 5,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Available Tag formats\n    |--------------------------------------------------------------------------\n    |\n    | A list of tags formats to print with each definition\n    |\n    */\n\n    'tags' =\u003e ['Tag', 'MetaName', 'MetaProperty', 'MetaProduct', 'TwitterCard'],\n];\n```\n\n### Using Meta outside Laravel\n\n#### Controller\n\n```php\nrequire __DIR__.'/vendor/autoload.php';\n\n// Check default settings\n$config = require __DIR__.'/src/config/config.php';\n\n$Meta = new Eusonlito\\LaravelMeta\\Meta($config);\n\n# Default title\n$Meta-\u003etitle('This is default page title to complete section title');\n\n# Default robots\n$Meta-\u003eset('robots', 'index,follow');\n\n# Section description\n$Meta-\u003eset('title', 'This is a detail page');\n$Meta-\u003eset('description', 'All about this detail page');\n$Meta-\u003eset('image', '/images/detail-logo.png');\n\n# Canonical URL\n$Meta-\u003eset('canonical', 'http://example.com');\n```\n\n#### Template\n\n```php\n\u003ctitle\u003e\u003c?= $Meta-\u003eget('title'); ?\u003e\u003c/title\u003e\n\n\u003c?= $Meta-\u003etag('robots'); ?\u003e\n\n\u003c?= $Meta-\u003etag('site_name', 'My site'); ?\u003e\n\u003c?= $Meta-\u003etag('url', getenv('REQUEST_URI')); ?\u003e\n\u003c?= $Meta-\u003etag('locale', 'en_EN'); ?\u003e\n\n\u003c?= $Meta-\u003etag('title'); ?\u003e\n\u003c?= $Meta-\u003etag('description'); ?\u003e\n\n\u003c?= $Meta-\u003etag('canonical'); ?\u003e\n\n# Print custom section image and a default image after that\n\u003c?= $Meta-\u003etag('image', '/images/default-logo.png'); ?\u003e\n```\n\n#### Updates from 2.*\n\n* ``Meta::meta('title', 'Section Title')`` \u003e ``Meta::set('title', 'Section Title')``\n* ``Meta::meta('title')`` \u003e ``Meta::get('title')``\n* ``Meta::tagMetaName('title')`` \u003e ``Meta::tag('title')``\n* ``Meta::tagMetaProperty('title')`` \u003e ``Meta::tag('title')``\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feusonlito%2Flaravel-meta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feusonlito%2Flaravel-meta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feusonlito%2Flaravel-meta/lists"}