PHPackages                             jegex/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jegex/laravel-seo

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jegex/laravel-seo
=================

This is my package laravel-seo

v0.1.0-alpha(1mo ago)00[2 PRs](https://github.com/jegex/laravel-seo/pulls)MITPHPPHP ^8.4CI passing

Since Apr 29Pushed 1mo agoCompare

[ Source](https://github.com/jegex/laravel-seo)[ Packagist](https://packagist.org/packages/jegex/laravel-seo)[ Docs](https://github.com/jegex/laravel-seo)[ GitHub Sponsors](https://github.com/jegex)[ RSS](/packages/jegex-laravel-seo/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (12)Versions (4)Used By (0)

Laravel SEO Package
===================

[](#laravel-seo-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/556860f7cacbefe007cb51d954ffbb5fb005165e4fe698ddbcab3ac4b21016d0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a656765782f6c61726176656c2d73656f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jegex/laravel-seo)[![GitHub Tests Action Status](https://camo.githubusercontent.com/6fbe74823d910105f479a53e136c3ea9f46c300de1305a3d063b343686359dc8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a656765782f6c61726176656c2d73656f2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/jegex/laravel-seo/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/880136b098bab748fcc24618a3c1eb14e6987b0ce396da857f4caee3e34a1024/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a656765782f6c61726176656c2d73656f2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/jegex/laravel-seo/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/c6a2ffc1aaafdf3ffaef15ae69a4048c717dec2c31b210183ef470f99b6245ed/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a656765782f6c61726176656c2d73656f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jegex/laravel-seo)

A comprehensive SEO package for Laravel inspired by Rank Math SEO (WordPress). Features include meta tags, Open Graph, Twitter Cards, template variables, sitemap generation, redirect management, and 404 tracking.

> **Note:** This is a **core SEO package** - no admin dashboard included. For a Filament admin dashboard, check out the separate `filament-seo` package.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/c53aea3564cd8a7c93c77784c45f641b0305ada2340e224b611aee970f018e80/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d73656f2e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-seo)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require jegex/laravel-seo
```

You can publish and run the migrations with:

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

You can publish the config file with:

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

Optionally, you can publish the views using

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

Quick Start
-----------

[](#quick-start)

### 1. Add Trait to Your Model

[](#1-add-trait-to-your-model)

```
use Jegex\LaravelSeo\Traits\HasSeo;

class Post extends Model
{
    use HasSeo;
}
```

### 2. Use in Your Blade Layout

[](#2-use-in-your-blade-layout)

```

    {{ seo()->render() }}

    @yield('content')

```

### 3. Configure Templates (config/seo.php)

[](#3-configure-templates-configseophp)

```
return [
    'site_name' => 'My Blog',
    'site_description' => 'A blog about Laravel',
    'separator' => ' - ',

    'templates' => [
        'post' => [
            'title' => '%title% %sep% %sitename%',
            'description' => '%excerpt%',
        ],
    ],

    'webmaster_verification' => [
        'google' => 'your-google-verification-code',
        'bing' => 'your-bing-verification-code',
    ],
];
```

Features
--------

[](#features)

### Template Variables (Rank Math Style)

[](#template-variables-rank-math-style)

Use these variables in your templates:

VariableDescription`%title%`Model title`%sitename%`Website name`%sitedesc%`Website description`%sep%`Separator (default: `-`)`%currentdate%`Current date`%currentyear%`Current year`%author%`Author name`%excerpt%`Content excerpt (160 chars)`%categories%`Categories list`%tags%`Tags list### Helper Functions

[](#helper-functions)

```
// Set SEO data
seo('title', 'My Page Title');
seo('description', 'Page description');
seo('og:image', '/path/to/image.jpg');

// Or use methods
seo()->setTitle('My Title')->setDescription('My Description');

// Parse templates manually
parse_seo_template('%title% %sep% %sitename%', ['title' => 'Hello']);
```

### Blade Components

[](#blade-components)

```

```

### Webmaster Verification

[](#webmaster-verification)

Add verification codes in `config/seo.php`:

```
'webmaster_verification' => [
    'google' => 'abc123...',
    'bing' => 'xyz789...',
    'pinterest' => 'pinterest-code',
    'yandex' => 'yandex-code',
],
```

### Redirect Management

[](#redirect-management)

```
use Jegex\LaravelSeo\Models\Redirect;

// Create a 301 redirect
Redirect::create([
    'from_url' => '/old-page',
    'to_url' => '/new-page',
    'type' => 301,
]);

// Create a regex redirect
Redirect::create([
    'from_url' => '#/blog/(.*)#',
    'to_url' => '/articles/$1',
    'type' => 301,
    'is_regex' => true,
]);

// 410 Gone
Redirect::create([
    'from_url' => '/deleted-page',
    'type' => 410,
]);
```

### Middleware

[](#middleware)

Add to your `app/Http/Kernel.php`:

```
protected $middleware = [
    // ...
    \Jegex\LaravelSeo\Http\Middleware\RedirectMiddleware::class,
    \Jegex\LaravelSeo\Http\Middleware\NotFoundTrackerMiddleware::class,
];
```

SEO Analysis
------------

[](#seo-analysis)

### CLI Command

[](#cli-command)

```
# Analyze all SEO entries
php artisan seo:analyze

# Analyze specific model
php artisan seo:analyze --model="App\Models\Post"

# Calculate and save scores
php artisan seo:analyze --calculate-scores
```

### Model Analysis

[](#model-analysis)

```
$entry = $post->seoEntry;

// Get full analysis
$analysis = $entry->analyze();
// [
//     'score' => 85,
//     'alerts' => ['Title is slightly long...'],
//     'checks' => [...],
//     'details' => [...]
// ]

// Get score only
$entry->calculateScore();
echo $entry->seo_score; // 85

// Get score label
echo $entry->getScoreLabel(); // 'Good', 'Needs Improvement', or 'Poor'
```

### Programmatic Analysis

[](#programmatic-analysis)

```
use Jegex\LaravelSeo\Services\AnalyzerService;

$analyzer = app(AnalyzerService::class);
$analysis = $analyzer->analyze($content, [
    'title' => 'My Title',
    'description' => 'My Description',
    'focus_keyword' => 'laravel seo',
]);

echo $analysis['score']; // 0-100
echo $analysis['alerts'][0]; // First alert message
```

Breadcrumbs
-----------

[](#breadcrumbs)

### Via Service

[](#via-service)

```
// Manual breadcrumbs
seo()->breadcrumbs()
    ->add('Home', '/')
    ->add('Blog', '/blog')
    ->add($post->title, $post->url());

// Auto from route
seo()->breadcrumbs()->fromRoute();

// Render
{{ seo()->breadcrumbs()->renderHtml() }}
{{ seo()->breadcrumbs()->renderSchema() }}
```

### Via Blade Component

[](#via-blade-component)

```

```

JSON-LD Structured Data
-----------------------

[](#json-ld-structured-data)

### Available Schema Types

[](#available-schema-types)

- `article` - Article/BlogPosting
- `website` - WebSite with SearchAction
- `organization` - Organization with contact info
- `breadcrumbs` - BreadcrumbList

### Creating Schema

[](#creating-schema)

```
// Via SEO service (auto-rendered)
seo()->addSchema('article')
    ->headline('My Article')
    ->author('John Doe')
    ->datePublished(now()->toIso8601String())
    ->image('https://example.com/image.jpg');

// Via Schema service
seo()->schema()
    ->website()
    ->name('My Site')
    ->url('/')
    ->potentialActionSearch('/search?q={search_term_string}');

// Organization schema
seo()->schema()
    ->organization()
    ->name('My Company')
    ->url('https://example.com')
    ->contactPoint('+1-234-567-8900', 'customer service');
```

### Rendering

[](#rendering)

```
{{-- In your layout, schemas auto-render with meta tags --}}
{{ seo()->render() }}

{{-- Or render schemas only --}}
{{ seo()->schema()->render() }}

{{-- Manual schema --}}

```

Complete Example
----------------

[](#complete-example)

### Controller

[](#controller)

```
class PostController extends Controller
{
    public function show(Post $post)
    {
        // Automatically uses HasSeo trait for defaults
        seo()->for($post);

        // Or manually override
        seo()->setTitle($post->title . ' | Custom Suffix');

        return view('posts.show', compact('post'));
    }
}
```

### View (posts/show.blade.php)

[](#view-postsshowbladephp)

```
@extends('layouts.app')

@section('content')

        {{ $post->title }}
        {{ $post->content }}

@endsection
```

### Layout (layouts/app.blade.php)

[](#layout-layoutsappbladephp)

```

    {{-- Render all SEO meta tags --}}
    {{ seo()->render() }}

    @stack('styles')

    @yield('content')

    @stack('scripts')

```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [jegex](https://github.com/jegex)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance92

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

41d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e33533e1c902dffe83701a75f166b7c20b32150f9c04426e0c1bc49a22701ca7?d=identicon)[jegex](/maintainers/jegex)

---

Top Contributors

[![jegex](https://avatars.githubusercontent.com/u/219070132?v=4)](https://github.com/jegex "jegex (26 commits)")

---

Tags

laravellaravel-seojegex

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.8k33.0M871](/packages/spatie-laravel-data)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.3M41](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

327482.0k25](/packages/codewithdennis-filament-select-tree)[nativephp/desktop

NativePHP for Desktop

37833.6k8](/packages/nativephp-desktop)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124581.3k](/packages/worksome-exchange)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

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