{"id":18905051,"url":"https://github.com/kfoobar/laravel-meta","last_synced_at":"2026-04-24T12:07:52.293Z","repository":{"id":57006027,"uuid":"238786660","full_name":"KFoobar/laravel-meta","owner":"KFoobar","description":"Meta and title tag management package for Laravel 5 and Laravel 6","archived":false,"fork":false,"pushed_at":"2020-12-11T19:21:37.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-24T23:47:30.594Z","etag":null,"topics":["blade-directives","facade","laravel","meta-tags","title-tag"],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/KFoobar.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}},"created_at":"2020-02-06T21:18:22.000Z","updated_at":"2022-10-03T20:25:07.000Z","dependencies_parsed_at":"2022-08-21T14:30:56.201Z","dependency_job_id":null,"html_url":"https://github.com/KFoobar/laravel-meta","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/KFoobar/laravel-meta","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KFoobar%2Flaravel-meta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KFoobar%2Flaravel-meta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KFoobar%2Flaravel-meta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KFoobar%2Flaravel-meta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KFoobar","download_url":"https://codeload.github.com/KFoobar/laravel-meta/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KFoobar%2Flaravel-meta/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262609551,"owners_count":23336735,"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":["blade-directives","facade","laravel","meta-tags","title-tag"],"created_at":"2024-11-08T09:10:24.940Z","updated_at":"2026-04-24T12:07:52.267Z","avatar_url":"https://github.com/KFoobar.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel package to manage meta and title tags\n\nThis package makes it easier to work with HTML meta and title tags in Laravel 5 and Laravel 6.\n\nThe package can be used in any controller with the facade or in any blade file with the facade or the blade directives.\n\nThe package supports most meta tags. It also supports the `\u003ctitle\u003e` tag and the `\u003clink\u003e` tag for canonical since they are commonly used.\n\n## Installation\n\nBegin by installing the package with Composer from your command line:\n\n```\n$ composer require kfoobar/laravel-meta\n```\n\n### Laravel 5.5 or later\n\nIf you use auto-discovery, you don't need to do anything more to enable the package.\n\n### Laravel 5.4 or earlier\n\nYou need to register the service provider with your Laravel application in `config/app.php`:\n\n```php\n'providers' =\u003e [\n    '...',\n    KFoobar\\LaravelMeta\\MetaServiceProvider::class,\n];\n```\n\nAlso add the facade to the same config file:\n\n```php\n'aliases' =\u003e [\n    '...',\n    'Meta'    =\u003e KFoobar\\LaravelMeta\\Facades\\Meta::class,\n];\n```\n\n## How to use\n\n### How to use the facade\n\nIf you want to set your tags in a controller, you'll need to add the namespace for the `Meta` facade.\n\n```php\n\u003c?php\n\nnamespace App\\Http\\Controllers\\Posts;\n\nuse App\\Http\\Controllers\\Controller;\nuse KFoobar\\LaravelMeta\\Facades\\Meta;\n\nclass PostController extends Controller\n{\n...\n```\n\n#### Set values\n\nYou can set the tag values in your controller with the `set` method.\n\n```php\npublic function index()\n{\n    Meta::set('title', 'Your new page title');\n    Meta::set('description', 'Your new meta description');\n    // or...\n    Meta::setTitle('Your new page title');\n    Meta::setDescription('Your new meta description');    \n}\n```\n\n#### Get values\n\nAnd if you need to, you can also get the values with the `get` method.\n\n```php\npublic function index()\n{\n    Meta::get('title', 'Default title if none is set');\n    Meta::get('description', 'Default description if none is set');\n    // or...\n    Meta::getTitle('Default title if none is set');\n    Meta::getDescription('Default description if none is set');\n }\n```\n\n#### Get the full html tag\n\nI you want the full html tag as a string, use the `tag` method.\n\n```php\n$titleTag = Meta::tag('title');\n$titleTag = Meta::tag('title', 'Default title if none is set');\n```\n\n#### Check if value is set\n\nIf you need the check if any value is set, use the `has` method.\n\n```php\nif (!Meta::has('title')) {\n    Meta::set('title', 'This is a fallback title');\n}\n```\n\n### How to use the blade directives\n\nYou can use the facade directly in you blade files, but there are a few blade directives that will make your blade files look a bit cleaner.\n\n#### Set values\n\nBy using the `@setMeta` directive, you can set the values of your title and meta tags in any blade file.\n\n```php\n@setMeta('title', 'Your new page title');\n@setMeta('description', 'Your new meta description');\n```\n\n#### Get values\n\nUse the `@getMeta` directive when you want to get the value of your title and meta tags.\n\n```php\n@getMeta('title')\n@getMeta('title', 'Default title if none is set')\n\n\u003ctitle\u003e\n    @getMeta('title', 'Default title if none is set')\n\u003c/title\u003e\n```\n\n#### Get the full html tag\n\nYou can use the `@getTag` directive when you want to print the full html tag.\n\n```php\n@getTag('title')\n@getTag('title', 'Default title if none is set')\n\n@getTag('description')\n@getTag('description', 'Default description if none is set')\n```\n\n#### Check if value is set\n\nWhen you need the check if any value is set, use the `@hasMeta` directive.\n\n```php\n@hasMeta('author')\n   \u003cmeta name=\"author\" content=\"@meta('author')\"\u003e\n@endhasMeta\n```\n\nYou can also use `@endif` instead of `@endhasMeta` if you prefer.\n\n## Example\n\nThis is our blade file:\n\n```php\n@getTag('description')\n@getTag('keywords')\n@getTag('robots', 'index, follow')\n@getTag('csrf-token')\n\n@getTag('title', 'Default title if none is set')\n\n@hasMeta('canonical')\n    @getTag('canonical')\n@endhasMeta\n```\n\nThis will be the output:\n\n```php\n\u003cmeta name=\"description\" content=\"Lorem ipsum dolor...\"\u003e\n\u003cmeta name=\"keywords\" content=\"lorem, ipsum, dolor\"\u003e\n\u003cmeta name=\"robots\" content=\"index, follow\"\u003e\n\u003cmeta name=\"csrf-token\" content=\"4ipX8A07Awf60ZUBPBfy...\"\u003e\n\n\u003ctitle\u003eDefault title if none is set\u003c/title\u003e\n\n\u003clink rel=\"canonical\" href=\"https://example.com/this-is-a-slug\"\u003e\n```\n\n## Contributing\n\nContributions are welcome!\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkfoobar%2Flaravel-meta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkfoobar%2Flaravel-meta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkfoobar%2Flaravel-meta/lists"}