PHPackages                             sebacarrasco93/laravel-simple-sitemap - 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. sebacarrasco93/laravel-simple-sitemap

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

sebacarrasco93/laravel-simple-sitemap
=====================================

Laravel Simple Sitemap

1.0.3(2mo ago)01.6k[2 PRs](https://github.com/sebacarrasco93/laravel-simple-sitemap/pulls)MITPHPPHP ^8.2CI passing

Since Mar 7Pushed 1w ago1 watchersCompare

[ Source](https://github.com/sebacarrasco93/laravel-simple-sitemap)[ Packagist](https://packagist.org/packages/sebacarrasco93/laravel-simple-sitemap)[ Docs](https://github.com/sebacarrasco93/laravel-simple-sitemap)[ GitHub Sponsors]()[ RSS](/packages/sebacarrasco93-laravel-simple-sitemap/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (4)Dependencies (24)Versions (13)Used By (0)

Laravel Simple Sitemap
======================

[](#laravel-simple-sitemap)

A very simple package: Create sitemaps "on the fly"

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

[](#installation)

You can install the package via composer:

```
composer require sebacarrasco93/laravel-simple-sitemap
```

You can publish the config file with:

```
php artisan vendor:publish --tag="simple-sitemap-config"
```

This is the contents of the published config file:

```
return [
    'default_frequency' => 'monthly',

    'default_priority' => '0.50',
];
```

Usage
-----

[](#usage)

Create a sitemap for Eloquent Collections

Let's assume that you want to make a sitemap of all the categories, you can do that in only 3 steps!

```
// app/Models/Category

use SebaCarrasco93\SimpleSitemap\Traits\SimpleSitemapCollection; // 👈 1: Import Trait

class Category extends Model
{
    use HasFactory;
    // ...
    use SimpleSitemapCollection; // 👈 2: Use the trait

    // ...

    // 👇 Step 3: Create getSitemapUrlAttribute() method and specify the full url
    public function getSitemapUrlAttribute(): string
    {
        return route('category.show', $this);
    }
}
```

Now, you can use it

```
// web.php, controller or equivalent

$categories = Category::get();

return SimpleSitemap::fromEloquentCollection($categories);
```

Can I short the syntax? Of course!

```
return Category::sitemap(); // Equivalent to SimpleSitemap::fromEloquentCollection(Category::get());
```

Advanced usage
--------------

[](#advanced-usage)

A sitemap for only active categories? Sure!

```
return Category::where('active', true)
    ->sitemap();
```

A sitemap for active, in desc order and paginate? It's Eloquent and Laravel!

```
$paginated_active_categories = Category::where('active', true)
    ->orderBy('desc', 'id')
    ->paginate();

return SimpleSitemap::fromEloquentCollection($paginated_active_categories);
```

Easy Peasy!

Add to a specific routes
------------------------

[](#add-to-a-specific-routes)

You can add to a custom routes in only 2 steps:

Adding the Middlewares

```
// app/Http/Kernel.php

// ...
protected $middlewareAliases = [
    // ...
    'sitemap' => \SebaCarrasco93\SimpleSitemap\Middleware\SimpleSitemap::class,
];
```

Using the Middleware:

You can add all your `get` routes. If you add another such as `post`, `patch`, `put`, etc. it will be ignored.

```
// web.php or equivalent

Route::get('your-route', [YourController::class])
    ->middleware('sitemap'); //  👈

Route::get('your-route', function () {
    return 'It works with a closure, too';
})->middleware('sitemap'); // 👈
```

### Advanced

[](#advanced)

If you don't wanna to add each one, you can add into your all php

```
// app/Providers/RouteServiceProvider.php
Route::middleware(['web', 'sitemap']) // 👈
    ->group(base_path('routes/web.php'));
```

Also, if you want to exclude a specific route from a group, you can add `sitemap:exclude` middleware

```
// web.php or equivalent

Route::get('to_exclude', function () {
    // You very important route to exclude
})->middleware('sitemap:exclude');
```

Now, you can see all your routes

```
return SimpleSitemap::routes();
```

Creating a index
----------------

[](#creating-a-index)

Optionally, you can create a index sitemap with your sitemap collections

```
$routes = [
    route('sitemaps/index-1'), // You can pass it as a route
    'https://yourdomain.com/sitemaps/index-2', // or, as full path
    '/sitemaps/index-3', // as a relative path, too
];

return SimpleSitemap::index($routes);
```

Custom frequency and priority
-----------------------------

[](#custom-frequency-and-priority)

If you want to customize each frequency or priority, you can add a migration

```
php artisan make:migration add_sitemap_columns_to_{your_table}_table
```

```
$table->addColumn('string', 'frequency')->nullable();
$table->addColumn('string', 'priority')->nullable();
```

You can also specify a custom frequency for a specific model

```
// app/Models/YourModel.php

public function getFrequencyAttribute(?string $frequency = null): string
{
    return $frequency ?? 'weekly';
}
```

Specify custom frequency to a specific model

```
// app/Models/YourModel.php

public function getPriorityAttribute(?string $priority = null): string
{
    return $priority ?? '0.1';
}
```

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)

- [Seba Carrasco Poblete](https://github.com/sebacarrasco93)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance91

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 78.7% 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 ~191 days

Total

5

Last Release

85d ago

PHP version history (2 changes)1.0.0PHP ^8.1

1.0.3PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/30738997?v=4)[Seba](/maintainers/sebacarrasco93)[@sebacarrasco93](https://github.com/sebacarrasco93)

---

Top Contributors

[![sebacarrasco93](https://avatars.githubusercontent.com/u/30738997?v=4)](https://github.com/sebacarrasco93 "sebacarrasco93 (48 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

laravelSeba Carrasco Pobletelaravel-simple-sitemap

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/sebacarrasco93-laravel-simple-sitemap/health.svg)

```
[![Health](https://phpackages.com/badges/sebacarrasco93-laravel-simple-sitemap/health.svg)](https://phpackages.com/packages/sebacarrasco93-laravel-simple-sitemap)
```

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/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.

329530.5k29](/packages/codewithdennis-filament-select-tree)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

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

Check Exchange Rates for any currency in Laravel.

124603.0k](/packages/worksome-exchange)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

199.4k](/packages/tarfin-labs-event-machine)

PHPackages © 2026

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