PHPackages                             achyutn/laravel-seo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. achyutn/laravel-seo

ActiveLibrary[Search &amp; Filtering](/categories/search)

achyutn/laravel-seo
===================

An opinionated Laravel package to manage SEO easily.

v1.4.0(3mo ago)21.2kMITPHPPHP &gt;=8.2

Since Jan 3Pushed 3mo agoCompare

[ Source](https://github.com/achyutkneupane/laravel-seo)[ Packagist](https://packagist.org/packages/achyutn/laravel-seo)[ GitHub Sponsors](https://github.com/achyutkneupane)[ Fund](https://buymeacoffee.com/achyutn)[ RSS](/packages/achyutn-laravel-seo/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (14)Used By (0)

Laravel SEO
===========

[](#laravel-seo)

[![Packagist Version](https://camo.githubusercontent.com/1c2206b7e70b189a4c05c097a6df2749ea6846c5d76a3896e5b31dabd6af569a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6163687975746e2f6c61726176656c2d73656f3f6c6162656c3d4c617465737425323056657273696f6e)](https://camo.githubusercontent.com/1c2206b7e70b189a4c05c097a6df2749ea6846c5d76a3896e5b31dabd6af569a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6163687975746e2f6c61726176656c2d73656f3f6c6162656c3d4c617465737425323056657273696f6e)[![Packagist Downloads](https://camo.githubusercontent.com/9b0be1e2e930af813ec2ce6145dc0d4fc28d466c798ec9f711de920e49c0bb3d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6163687975746e2f6c61726176656c2d73656f3f6c6162656c3d5061636b6167697374253230446f776e6c6f616473)](https://camo.githubusercontent.com/9b0be1e2e930af813ec2ce6145dc0d4fc28d466c798ec9f711de920e49c0bb3d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6163687975746e2f6c61726176656c2d73656f3f6c6162656c3d5061636b6167697374253230446f776e6c6f616473)[![Packagist Stars](https://camo.githubusercontent.com/c96ea1d8046368723b1b1a09f5aa9b95e87a31eafe85c5e18d423bbe5ca5f364/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f6163687975746e2f6c61726176656c2d73656f3f6c6162656c3d5374617273)](https://camo.githubusercontent.com/c96ea1d8046368723b1b1a09f5aa9b95e87a31eafe85c5e18d423bbe5ca5f364/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f6163687975746e2f6c61726176656c2d73656f3f6c6162656c3d5374617273)[![Lint & Test PR](https://github.com/achyutkneupane/laravel-seo/actions/workflows/prlint.yml/badge.svg)](https://github.com/achyutkneupane/laravel-seo/actions/workflows/prlint.yml)

An opinionated Laravel SEO package to manage SEO on Eloquent models. This package makes use of an un-opinionated package [ralphjsmit/laravel-seo](https://github.com/ralphjsmit/laravel-seo) and adds a pattern of auto-generating SEO metadata and sitemaps for Eloquent models with customization.

This package lets you generate SEO metadata and sitemap directly from Eloquent models without manually wiring SEO data in controllers or views. It supports multiple schema types including [Blog](#blog-schema), [Product](#product-schema), and generic [Page](#page-schema) schema.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require achyutn/laravel-seo
```

You must publish package config and migration stubs to your application using the following command:

```
php artisan vendor:publish --tag="laravel-seo"
```

This generates a `config/seo.php` configuration file and a migration file for the `seo` table in your database.

> `ralphjsmit/laravel-seo` will also be installed as a dependency. Publishing the configuration and migration of that package will break the functionality of this package.
> If you want full customization, I recommend you to check out that package directly from its [GitHub repository](https://github.com/ralphjsmit/laravel-seo).

Next, run the migration to create the `seo` table:

```
php artisan migrate
```

Usage
-----

[](#usage)

To use the package, simply add the [`AchyutN\LaravelSEO\Traits\InteractsWithSEO`](src/Traits/InteractsWithSEO.php) trait to any Eloquent model you want to manage SEO for.

```
use AchyutN\LaravelSEO\Traits\InteractsWithSEO;

class Post extends Model
{
    use InteractsWithSEO;

    // ...
}
```

This will automatically use the default columns (title, description, etc). You can also auto-generate [breadcrumbs](#breadcrumbs) and [schema markup](#schema-types) for your model by implementing the respective methods or traits.

### Generate SEO Entries

[](#generate-seo-entries)

After adding the trait to your model, you need to generate SEO entries for existing records. You can do this by running the following Artisan command:

```
php artisan seo:generate
```

It also supports re-generating SEO entries for models that already have SEO data. You can use the `--regenerate` flag to update existing entries:

```
php artisan seo:generate --regenerate
```

### Schema Types

[](#schema-types)

This package supports multiple schema types using traits:

- [BlogSchema](#blog-schema) for blog posts
- [ProductSchema](#product-schema) for products (e-commerce)
- [PageSchema](#page-schema) for generic pages

Each schema trait implements a `buildSchema(SchemaCollection $schema, ResolvedSEO $resolvedSEO)` method, which receives resolved SEO data from your model. To use any schema, add the corresponding trait to your model along with the interface `AchyutN\LaravelSEO\Contracts\HasMarkup`.

#### Blog Schema

[](#blog-schema)

To use the Blog schema, add the `AchyutN\LaravelSEO\Schemas\BlogSchema` trait to your model:

```
use AchyutN\LaravelSEO\Contracts\HasMarkup;
use AchyutN\LaravelSEO\Schemas\BlogSchema;

class Post extends Model implements HasMarkup
{
    use InteractsWithSEO;
    use BlogSchema;

    // ...
}
```

#### Product Schema

[](#product-schema)

To use the Product schema, add the `AchyutN\LaravelSEO\Schemas\ProductSchema` trait to your model:

```
use AchyutN\LaravelSEO\Contracts\HasMarkup;
use AchyutN\LaravelSEO\Schemas\ProductSchema;

class Product extends Model implements HasMarkup
{
    use InteractsWithSEO;
    use ProductSchema;

    // ...
}
```

#### Page Schema

[](#page-schema)

To use the Page schema, add the `AchyutN\LaravelSEO\Schemas\PageSchema` trait to your model:

```
use AchyutN\LaravelSEO\Contracts\HasMarkup;
use AchyutN\LaravelSEO\Schemas\PageSchema;

class Page extends Model implements HasMarkup
{
    use InteractsWithSEO;
    use PageSchema;

    // ...
}
```

### Breadcrumbs

[](#breadcrumbs)

You can also manage breadcrumbs by defining a `breadcrumbs()` method on your model that returns an array of [`Breadcrumb`](src/Data/Breadcrumb.php) items.

```
use AchyutN\LaravelSEO\Data\Breadcrumb;

class Post extends Model
{
    use InteractsWithSEO;

    public function breadcrumbs(): array
    {
        return [
            new Breadcrumb(label: 'Home', url: route('home')),
            new Breadcrumb(label: 'Blog', url: route('blog.index')),
            new Breadcrumb(label: $this->title, url: route('blog.show', $this)),
        ];
    }
}
```

### Rendering SEO Tags

[](#rendering-seo-tags)

To render the SEO tags in your views, you can use the following Blade directive:

```
{!! seo($model) !!}
```

Replace `$model` with the instance of your Eloquent model.

### Sitemaps

[](#sitemaps)

Once you have models using the `InteractsWithSEO` trait, you automatically have them included in your sitemap. You can access the sitemap in two formats:

- XML Sitemap: `/sitemap.xml`
- TXT Sitemap: `/sitemap.txt`

The XML sitemap will be auto-injected in your blade layout along with the metadata.

### Customization

[](#customization)

This package resolves SEO data using a simple priority order:

1. A custom `*Value()` method, if defined on the model
2. A custom `$*Column` property, if defined on the model
3. A default column name

You can customize each field independently.

#### Resolution Priority

[](#resolution-priority)

For each field:

1. `*Value()` method
2. `$*Column` property
3. Default column name

Methods always take precedence over properties.

#### Supported Override Methods

[](#supported-override-methods)

Define these **on your model** when the value is computed or derived. Organized by context:

##### Common Methods

[](#common-methods)

MethodReturn TypeWhen to use`titleValue()``?string`Computed or dynamic title`descriptionValue()``?string`Generated description`categoryValue()``?string`Derived category`imageValue()``?string`Media URL`authorValue()``?string`Relation-based author`authorUrlValue()``?string`Author profile link`publisherValue()``?string`Brand or company name`publisherUrlValue()``?string`Publisher homepage`tagsValue()``array`Normalized tags`urlValue()``?string`The page URL`publishedAtValue()``?Carbon`Computed publish date`modifiedAtValue()``?Carbon`Computed updated date`pageTypeValue()``?string`Custom page type##### Product-Specific Methods

[](#product-specific-methods)

MethodReturn TypeWhen to use`brandValue()``?string`Product brand`priceValue()``?float`Product price`discountPriceValue()``?float`Discounted price`currencyValue()``?string`Price currency`availabilityValue()``bool`Product availability`skuValue()``?string`Product SKU##### Page-Specific Methods

[](#page-specific-methods)

MethodReturn TypeWhen to use`pageTypeValue()``?string`Type of page (landing, about, etc.)##### Example

[](#example)

```
class Product extends Model
{
    use InteractsWithSEO;

    protected function priceValue(): ?float
    {
        return $this->price;
    }

    protected function availabilityValue(): bool
    {
        return $this->is_available;
    }
}
```

#### Supported Properties

[](#supported-properties)

Define these **on your Eloquent model** to change which column is used. Organized by context:

##### Common Properties

[](#common-properties)

PropertyDefaultPurpose`$titleColumn``title`Page title`$descriptionColumn``description`Meta description`$categoryColumn``category`Content category`$imageColumn``image`Open Graph image`$authorColumn``author`Author name`$authorUrlColumn``author_url`Author profile URL`$publisherColumn``publisher`Publisher name`$publisherUrlColumn``publisher_url`Publisher URL`$tagsColumn``tags`Tags or keywords`$urlColumn``url`The page URL`$publishedAtColumn``created_at`Publish date`$modifiedAtColumn``updated_at`Updated date`$pageTypeColumn``page_type`Page type##### Product-Specific Properties

[](#product-specific-properties)

PropertyDefaultPurpose`$brandColumn``brand`Product brand`$priceColumn``price`Product price`$discountPriceColumn``discount_price`Discounted price`$currencyColumn``currency`Price currency`$availabilityColumn``is_available`Product availability`$skuColumn``sku`Product SKU##### Example

[](#example-1)

```
class Product extends Model
{
    use InteractsWithSEO;

    protected string $priceColumn = 'product_price';
    protected string $brandColumn = 'product_brand';
}
```

#### Notes

[](#notes)

- All overrides are optional
- Do not define both a property and a method unless intentional
- IDEs and static analyzers understand all extension points via PHPDoc

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE.md).

Contributing
------------

[](#contributing)

Contributions are welcome! Please create a pull request or open an issue if you find any bugs or have feature requests.

Support
-------

[](#support)

If you find this package useful, please consider starring the repository on GitHub to show your support.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance80

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

12

Last Release

105d ago

PHP version history (2 changes)v1.0.0PHP &gt;=8.0

v1.1.0PHP &gt;=8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/52259760?v=4)[achyutn](/maintainers/achyutn)[@AchyutN](https://github.com/AchyutN)

---

Top Contributors

[![achyutkneupane](https://avatars.githubusercontent.com/u/30431426?v=4)](https://github.com/achyutkneupane "achyutkneupane (143 commits)")

---

Tags

laravelphpsearchseosearchlaravelSitemapseo

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/achyutn-laravel-seo/health.svg)

```
[![Health](https://phpackages.com/badges/achyutn-laravel-seo/health.svg)](https://phpackages.com/packages/achyutn-laravel-seo)
```

###  Alternatives

[ymigval/laravel-indexnow

Laravel Service Library for notifying search engines about the latest content changes on their URLs using IndexNow.

3410.2k](/packages/ymigval-laravel-indexnow)[remoblaser/search

A simple to implement Search for your Application

101.5k](/packages/remoblaser-search)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
