{"id":20012317,"url":"https://github.com/archtechx/laravel-seo","last_synced_at":"2025-05-14T20:06:38.604Z","repository":{"id":38019350,"uuid":"370032356","full_name":"archtechx/laravel-seo","owner":"archtechx","description":"SEO package for Laravel","archived":false,"fork":false,"pushed_at":"2025-03-06T16:39:22.000Z","size":94,"stargazers_count":313,"open_issues_count":6,"forks_count":32,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-14T01:49:33.467Z","etag":null,"topics":["laravel","seo"],"latest_commit_sha":null,"homepage":"https://archte.ch/blog/introducing-laravel-seo","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/archtechx.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":"2021-05-23T11:17:02.000Z","updated_at":"2025-04-07T19:24:51.000Z","dependencies_parsed_at":"2024-03-12T13:31:39.463Z","dependency_job_id":"60c1803d-dc7c-4f3c-bad5-68e48fc3847d","html_url":"https://github.com/archtechx/laravel-seo","commit_stats":{"total_commits":53,"total_committers":10,"mean_commits":5.3,"dds":0.3207547169811321,"last_synced_commit":"3a17c8ee117cfa2655dded5e997dfaf75e4ec1eb"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":"archtechx/template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archtechx%2Flaravel-seo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archtechx%2Flaravel-seo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archtechx%2Flaravel-seo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archtechx%2Flaravel-seo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/archtechx","download_url":"https://codeload.github.com/archtechx/laravel-seo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248809024,"owners_count":21164895,"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":["laravel","seo"],"created_at":"2024-11-13T07:29:44.133Z","updated_at":"2025-04-14T01:49:38.776Z","avatar_url":"https://github.com/archtechx.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel SEO\n\nThis is a simple and extensible package for improving SEO via meta tags, such as OpenGraph tags.\n\nBy default, it uses `\u003ctitle\u003e` and OpenGraph tags. It also ships with a Twitter extension. You're, of course, free to write your own extensions as needed.\n\n**Features**:\n- Setting SEO tags from PHP\n- Setting SEO tags from Blade\n- Integration with [Flipp](https://useflipp.com) and [Previewify](https://previewify.app), to automatically generate cover images\n- Custom extension support\n- Expressive \u0026 simple API\n- Customizable views\n\nExample usage:\n```php\nseo()\n    -\u003etitle($post-\u003etitle)\n    -\u003edescription($post-\u003eexcerpt)\n    -\u003etwitter()\n    -\u003eflipp('blog')\n\n// Adds OpenGraph tags\n// Adds Twitter card tags\n// Generates social image using Flipp and sets it as the cover photo\n```\n\n## Installation\n\n```sh\ncomposer require archtechx/laravel-seo\n```\n\nAnd add the following line to your layout file's `\u003chead\u003e` tag:\n\n```html\n\u003cx-seo::meta /\u003e\n```\n\n## Usage\n\nThe package can be used from any PHP code, or specifically from Blade using the `@seo` directive.\n\n### PHP\n\nUse the `seo()` helper to retrieve the SeoManager instance, on which you can call the following methods:\n\nAvailable methods:\n```js\nsite(string $site)\nurl(string $url)\ntitle(string $title)\ndescription(string $description)\nimage(string $url)\ntype(string $type)\nlocale(string $locale)\n\ntwitterCreator(string $username)\ntwitterSite(string $username)\ntwitterTitle(string $title)\ntwitterDescription(string $description)\ntwitterImage(string $url)\n```\n\nExample usage:\n\n```php\nseo()-\u003etitle('foo')-\u003edescription('bar')\n```\n\n### Blade views\n\nYou can use the `@seo` directive to call the methods from Blade:\n\n```html\n@seo('title') // Echoes the title\n@seo('title', 'foo') // Sets the title \u0026 echoes it\n@seo(['title' =\u003e 'foo']) // Sets the title without echoing it\n```\n\nIn general, you'll want to use `@seo(['title' =\u003e 'foo'])` at the start of a view — to set the values — and `@seo('title')` inside the view if you wish to fetch the value.\n\nThat is, if you'll use the helpers in Blade at all. Some apps will only use the PHP helper.\n\nFor Twitter, use the `twitter.author` format, e.g. `@seo('twitter.author')`.\n\n### Twitter\n\nBy default, no Twitter tags will be included. If you manually enable the extension by calling:\n\n```php\nseo()-\u003etwitter();\n```\n\nin a service provider for example, the extension will be enabled.\n\nOnce it's enabled, it will copy all default (OpenGraph) values and use them for the Twitter card schema.\n\nWhen a value is set specifically for Twitter, it will be prioritized over the general fallback values.\n\n```php\nseo()-\u003etwitterTitle('About us')\n```\n\n### Favicons\n\nBy default, no favicon links will be included. You can manually enable the extension by calling:\n\n```php\nseo()-\u003efavicon();\n```\n\n## Generating favicons\n\nTo generate favicon, run:\n\n```\nphp artisan seo:generate-favicons public/path-to/logo.png\n```\n\nfrom the artisan console. If no path argument is given we'll fallback to `public/assets/logo.png`.\n\nWe'll generate a 32x32px `public/favicon.ico` \u0026 `public/favicon.png` icon. This should be sufficient for most cases.\n\n**Please keep in mind that you need to install the [imagick](https://pecl.php.net/package/imagick) php extension and [intervention/image](http://image.intervention.io/) composer package.**\n\n### Defaults\n\nTo configure default values, call the methods with the `default` argument:\n\n```php\nseo()\n    -\u003etitle(default: 'ArchTech — Meticulously architected web applications')\n    -\u003edescription(default: 'We are a web development agency that ...');\n```\n\n### Extra tags\n\nTo add more tags to the document head, you can use the `tag()` and `rawTag()` methods:\n\n```php\nseo()-\u003etag('fb:image', asset('foo'));\nseo()-\u003erawTag('\u003cmeta property=\"fb:url\" content=\"bar\"\u003e');\nseo()-\u003erawTag('fb_url', '\u003cmeta property=\"fb:url\" content=\"bar\"\u003e'); // Keyed, allows overrides later on\n```\n\n### Canonical URL\n\nTo enable the `og:url` and canonical URL `link` tags, call:\n\n```php\nseo()-\u003ewithUrl();\n```\n\nThis will make the package read from `request()-\u003eurl()` (the current URL *without* the query string).\n\nIf you wish to change the URL, call `seo()-\u003eurl()`:\n\n```php\nseo()-\u003eurl(route('products.show', $this-\u003eproduct));\n```\n\n### Locale\n\nTo set the `og:locale` property:\n\n```php\nseo()-\u003elocale('de_DE');\n```\n\nExpected format is `language_TERRITORY`.\n\n### Modifiers\n\nYou may want to modify certain values before they get inserted into the template. For example, you may want to suffix the meta `\u003ctitle\u003e` with `| ArchTech` when it has a non-default value.\n\nTo do that, simply add the `modify` argument to the method calls like this:\n\n```php\nseo()-\u003etitle(modify: fn (string $title) =\u003e $title . ' | ArchTech');\n```\n\nYou can, of course, combine these with the defaults:\n\n```php\nseo()-\u003etitle(\n    default: 'ArchTech — Meticulously architected web applications',\n    modify: fn (string $title) =\u003e $title . ' | ArchTech'\n);\n```\n\nWhich will make the package use the default if no title is provided, and if a title is provided using e.g. `seo()-\u003etitle('Blog')`, it will be modified **right before being inserted into the template**.\n\n### Flipp integration\n\nFirst, you need to add your Flipp API keys:\n1. Add your API key to the `FLIPP_KEY` environment variable. You can get the key [here](https://useflipp.com/settings/profile/api).\n2. Go to `config/services.php` and add:\n    ```php\n    'flipp' =\u003e [\n        'key' =\u003e env('FLIPP_KEY'),\n    ],\n    ```\n\nThen, register your templates, for example in `AppServiceProvider`:\n```php\nseo()-\u003eflipp('blog', 'v8ywdwho3bso');\nseo()-\u003eflipp('page', 'egssigeabtm7');\n```\n\nAfter that, you can use the templates by calling `seo()-\u003eflipp()` like this:\n```php\nseo()-\u003eflipp('blog', ['title' =\u003e 'Foo', 'content' =\u003e 'bar'])`\n```\n\nThe call will set the generated image as the OpenGraph and Twitter card images. The generated URLs are signed.\n\nIf no data array is provided, the method will use the `title` and `description` from the current SEO config:\n\n```php\nseo()-\u003etitle($post-\u003etitle);\nseo()-\u003edescription($post-\u003eexcerpt);\nseo()-\u003eflipp('blog');\n```\n\nThe `flipp()` method also returns a signed URL to the image, which lets you use it in other places, such as blog cover images.\n```php\n\u003cimg alt=\"@seo('title')\" src=\"@seo('flipp', 'blog')\"\u003e\n```\n\n### Previewify integration\n\nFirst, you need to add your Previewify API keys:\n1. Add your API key to the `PREVIEWIFY_KEY` environment variable. You can get the key [here](https://previewify.app/app/account).\n2. Go to `config/services.php` and add:\n    ```php\n    'previewify' =\u003e [\n        'key' =\u003e env('PREVIEWIFY_KEY'),\n    ],\n    ```\n\nThen, register your templates, for example in `AppServiceProvider`:\n```php\nseo()-\u003epreviewify('blog', 24);\nseo()-\u003epreviewify('page', 83);\n```\n\nAfter that, you can use the templates by calling `seo()-\u003epreviewify()` like this:\n```php\nseo()-\u003epreviewify('blog', ['title' =\u003e 'Foo', 'content' =\u003e 'bar'])`\n```\n\nThe call will set the generated image as the OpenGraph and Twitter card images. The generated URLs are signed.\n\nIf no data array is provided, the method will use the `title` and `description` from the current SEO config:\n\n```php\nseo()-\u003etitle($post-\u003etitle);\nseo()-\u003edescription($post-\u003eexcerpt);\nseo()-\u003epreviewify('blog');\n```\n\nThe `previewify()` method also returns a signed URL to the image, which lets you use it in other places, such as blog cover images.\n```php\n\u003cimg alt=\"@seo('title')\" src=\"@seo('previewify', 'blog')\"\u003e\n```\n\n\u003e **Note**\n\u003e The `previewify:` prefix will be automatically prepended to all provided data keys.\n\n## Examples\n\n### Service Provider\n\nThis example sets the default state in a service provider's `boot()` method:\n\n```php\nseo()\n    -\u003esite('ArchTech — Meticulously architected web applications')\n    -\u003etitle(\n        default: 'ArchTech — Meticulously architected web applications',\n        modify: fn (string $title) =\u003e $title . ' | ArchTech'\n    )\n    -\u003edescription(default: 'We are a development agency ...')\n    -\u003eimage(default: fn () =\u003e asset('header.png'))\n    -\u003eflipp('blog', 'o1vhcg5npgfu')\n    -\u003etwitterSite('@archtechx');\n```\n\n### Controller\n\nThis example configures SEO metadata from a controller.\n\n```php\npublic function show(Post $post)\n{\n    seo()\n        -\u003etitle($post-\u003etitle)\n        -\u003edescription(Str::limit($post-\u003econtent, 50))\n        -\u003eflipp('blog', ['title' =\u003e $page-\u003etitle, 'content' =\u003e $page-\u003eexcerpt]);\n\n    return view('blog.show', compact($post));\n}\n```\n\n### View\n\nThis example uses a Blade view that sets global SEO config using the values that are passed to the view.\n\n```html\n@seo(['title' =\u003e $page-\u003ename])\n@seo(['description' =\u003e $page-\u003eexcerpt])\n@seo(['flipp' =\u003e 'content'])\n\n\u003ch1\u003e{{ $page-\u003etitle }}\u003c/h1\u003e\n\u003cp\u003e{{ $page-\u003eexcerpt }}\u003c/p\u003e\n\n\u003cp class=\"prose\"\u003e\n    {{ $page-\u003ebody }}\n\u003c/p\u003e\n```\n\n## Customization\n\nThis package is completely flexible, and can be customized either by having its views modified (to change the existing templates), or by you developing an extension (to add more templates).\n\n### Views\n\nYou can publish the Blade views by running `php artisan vendor:publish --tag=seo-views`.\n\n### Extensions\n\nTo use a custom extension, create a Blade *component* with the desired meta tags. The component should read data using `{{ seo()-\u003eget('foo') }}` or `@seo('foo')`.\n\nFor example:\n\n```php\n\u003cmeta name=\"facebook-title\" content=\"@seo('facebook.foo')\"\u003e\n```\n\nOnce your view is created, register the extension:\n\n```php\nseo()-\u003eextension('facebook', view: 'my-component');\n// The extension will use \u003cx-my-component\u003e\n```\n\nTo set data for an extension (in our case `facebook`), simply prefix calls with the extension name in camelCase, or use the `-\u003eset()` method:\n\n```php\nseo()-\u003efacebookFoo('bar');\nseo()-\u003efacebookTitle('About us');\nseo()-\u003eset('facebook.description', 'We are a web development agency that ...');\nseo(['facebook.description' =\u003e 'We are a web development agency that ...']);\n```\n\nTo disable an extension, set the second argument in the `extension()` call to false:\n\n```php\nseo()-\u003eextension('facebook', false);\n```\n\n## Development\n\nRun all checks locally:\n\n```sh\n./check\n```\n\nCode style will be automatically fixed by php-cs-fixer.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchtechx%2Flaravel-seo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farchtechx%2Flaravel-seo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchtechx%2Flaravel-seo/lists"}