PHPackages                             veiliglanceren/laravel-seo-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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. veiliglanceren/laravel-seo-sitemap

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

veiliglanceren/laravel-seo-sitemap
==================================

Laravel Sitemap package to optimize your website in search engines

2.2.0(9mo ago)4947[1 PRs](https://github.com/VeiligLanceren-nl/laravel-seo-sitemap/pulls)MITPHPPHP ^8.1CI passing

Since Mar 31Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/VeiligLanceren-nl/laravel-seo-sitemap)[ Packagist](https://packagist.org/packages/veiliglanceren/laravel-seo-sitemap)[ RSS](/packages/veiliglanceren-laravel-seo-sitemap/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (34)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/26d9e8b07b36cf3e679b95ce255a735851364e291c20f4633eecfa53e61159ec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7665696c69676c616e636572656e2f6c61726176656c2d73656f2d736974656d61702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/veiliglanceren/laravel-seo-sitemap)[![Total Downloads](https://camo.githubusercontent.com/48708e5e26d7ca7315adc49205c88620cd43910f10199966f6dc847805647ae5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7665696c69676c616e636572656e2f6c61726176656c2d73656f2d736974656d61702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/veiliglanceren/laravel-seo-sitemap)[![Laravel Versions](https://camo.githubusercontent.com/95f93db2cc8fe0bbc11c1790289c23a1eba7514e5aa5f64d3330e4c53786b2d2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d2535453130253743253545313125374325354531322e2a2d626c7565)](https://camo.githubusercontent.com/95f93db2cc8fe0bbc11c1790289c23a1eba7514e5aa5f64d3330e4c53786b2d2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d2535453130253743253545313125374325354531322e2a2d626c7565)[![PHP Versions](https://camo.githubusercontent.com/eabb6c70fc9cc3e8f4c30c299eb32e540756e2878fb6cf1758cac12d9b58947f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533455f382e312d626c7565)](https://camo.githubusercontent.com/eabb6c70fc9cc3e8f4c30c299eb32e540756e2878fb6cf1758cac12d9b58947f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533455f382e312d626c7565)

---

Laravel SEO Sitemap
===================

[](#laravel-seo-sitemap)

Want better Google rankings? Generating a clean and up-to-date sitemap is one of the easiest wins for your website’s SEO. With this package, your sitemap is always synced with your route and content structure, no manual edits needed. Search engines like Google and Bing use your sitemap to crawl your site smarter and faster, which means your new pages and updates show up in search results sooner. Whether you're running a blog, webshop, or custom platform, an automated sitemap gives you an edge in visibility and indexing accuracy.

**Lightweight. Extensible. Template-driven.**

🚀 Features of SEO Laravel Sitemap
---------------------------------

[](#-features-of-seo-laravel-sitemap)

- 🔍 Automatic sitemap generation from named routes via `->sitemap()`
- 🧩 Advanced route templates via `->sitemapUsing(MyTemplate::class)`
- 🧠 Built-in `Template` abstract with helpers like `urlsFromModel()`
- ✏️ Configure `lastmod`, `priority`, `changefreq` per URL
- 💾 Save or serve sitemaps via disk or route
- 🧪 Fully tested with Pest and Laravel Testbench
- 📦 Optional meta-tag injection in ``
- ✅ Laravel 10, 11, and 12 support

`📦` Installation of the Laravel sitemap package
-----------------------------------------------

[](#-installation-of-the-laravel-sitemap-package)

This package is quick to set up and works out-of-the-box with Laravel 10, 11, and 12. After installing via Composer, you can instantly publish the sitemap route and configuration using a single command. The `php artisan sitemap:install` command automatically adds a new `sitemap.php` route file and wires it into your existing web.php, so your sitemap is live without extra setup. It’s the easiest way to boost your SEO visibility with structured sitemap data.

```
composer require veiliglanceren/laravel-seo-sitemap
```

Publish the route &amp; config:

```
php artisan sitemap:install
php artisan vendor:publish --tag=sitemap-config
```

---

`🧭` How to use the sitemap package
----------------------------------

[](#-how-to-use-the-sitemap-package)

This package offers a clean and developer-friendly approach to sitemap generation in Laravel. Whether you're working with static pages or dynamic content from models, adding them to your sitemap is seamless. Use a single macro call for simple routes, or create powerful model-driven templates using the built-in abstract `Template` class to handle large, dynamic datasets. With just a few lines of code, your entire site structure becomes SEO-friendly and ready for search engine indexing.

### `✅` Static routes implemented in sitemap by 1 line in the routes/web.php file

[](#-static-routes-implemented-in-sitemap-by-1-line-in-the-routeswebphp-file)

The `Route` is getting implemented by calling the `->sitemap()` Macro.

```
use VeiligLanceren\LaravelSeoSitemap\Support\Enums\ChangeFrequency;

Route::get('/contact', ContactController::class)
    ->name('contact')
    ->sitemap()
    ->changefreq(ChangeFrequency::WEEKLY)
    ->priority('0.8');
```

#### Available `Route` Macros

[](#available-route-macros)

The package includes expressive route macros that make it easy to configure sitemap settings directly in your `routes/web.php` file.

##### `->sitemap()`

[](#-sitemap)

Marks the route as sitemap-included.

```
Route::get('/about', AboutController::class)
    ->name('about')
    ->sitemap();
```

##### `->changefreq(ChangeFrequency $frequency)`

[](#-changefreqchangefrequency-frequency)

Defines how frequently the content at the URL is likely to change.

```
use VeiligLanceren\LaravelSeoSitemap\Support\Enums\ChangeFrequency;

Route::get('/blog', BlogController::class)
    ->name('blog.index')
    ->sitemap()
    ->changefreq(ChangeFrequency::WEEKLY);
```

##### `->priority(string $priority)`

[](#-prioritystring-priority)

Sets the priority of this URL relative to other URLs on your site.

```
Route::get('/contact', ContactController::class)
    ->name('contact')
    ->sitemap()
    ->priority('0.8');
```

##### `->lastmod(string|DateTimeInterface $date)`

[](#-lastmodstringdatetimeinterface-date)

Sets the last modification date of the URL.

```
Route::get('/about', AboutController::class)
    ->name('about')
    ->sitemap()
    ->lastmod('2024-05-01');
```

> 💡 These macros can be chained for fluent configuration and better readability.

### `🧩` Model-driven Template class for easy implementation in sitemap

[](#-model-driven-template-class-for-easy-implementation-in-sitemap)

Use a custom `Template` that extends the abstract `Template` class:

```
// routes/web.php
Route::get('/blog/{slug}', BlogController::class)
    ->name('blog.show')
    ->sitemapUsing(\App\Sitemap\Templates\PostTemplate::class);
```

#### Example custom `Template` for implementing dynamic routes in sitemap

[](#example-custom-template-for-implementing-dynamic-routes-in-sitemap)

Read more about all of the helper functions: [template helper functions](docs/template-helper-functions.md)

```
namespace App\Sitemap\Templates;

use App\Models\Post;
use Illuminate\Routing\Route;
use VeiligLanceren\LaravelSeoSitemap\Sitemap\Item\Url;
use VeiligLanceren\LaravelSeoSitemap\Sitemap\Template;

class PostTemplate extends Template
{
    public function generate(Route $route): iterable
    {
        yield from $this->urlsFromModel(Post::class, $route, function (Post $post, Route $route) {
            return Url::make(route($route->getName(), ['slug' => $post->slug]))
                ->lastmod($post->updated_at)
                ->priority(0.6);
        });
    }
}
```

---

`📂` Make an index for multiple sitemaps
---------------------------------------

[](#-make-an-index-for-multiple-sitemaps)

Generate an index that references multiple sitemap files (e.g. per section):

```
use VeiligLanceren\LaravelSeoSitemap\Sitemap\SitemapIndex;

$sitemapIndex = SitemapIndex::make('https://example.com/sitemap-pages.xml')
    ->add('https://example.com/sitemap-posts.xml');
```

You can dynamically add entries with an optional `lastmod` and pretty-print XML:

```
$sitemapIndex->add('https://example.com/sitemap-products.xml', now());

Storage::disk('public')->put('sitemap.xml', $sitemapIndex->toXml());
```

Alternatively, mark routes with an index and let the CLI generate the index and files for you:

```
Route::get('/blog', fn () => 'Blog')
    ->sitemapIndex('blog');

Route::get('/pages', fn () => 'Pages')
    ->sitemapIndex('pages');

// php artisan sitemap:generate
```

This will produce `sitemap-blog.xml`, `sitemap-pages.xml` and an `sitemap.xml` index linking to them.

📖 Read more: [docs/sitemapindex.md](docs/sitemapindex.md)

---

`🧪` Generating sitemaps
-----------------------

[](#-generating-sitemaps)

```
use VeiligLanceren\LaravelSeoSitemap\Facades\Sitemap;

Sitemap::fromRoutes()
    ->getSitemap()
    ->save('sitemap.xml', 'public');
```

Or use the CLI:

```
php artisan sitemap:generate
```

---

`🖼` Add images to the sitemap
-----------------------------

[](#-add-images-to-the-sitemap)

### Using `Url` instances directly

[](#using-url-instances-directly)

```
use VeiligLanceren\LaravelSeoSitemap\Sitemap\Item\Url;
use VeiligLanceren\LaravelSeoSitemap\Sitemap\Item\Image;

$url = Url::make('https://example.com')
    ->addImage(Image::make('https://example.com/image1.jpg')->title('Hero 1'))
    ->addImage(Image::make('https://example.com/image2.jpg')->title('Hero 2'));
```

### Via route macros

[](#via-route-macros)

```
Route::get('/about', AboutController::class)
    ->name('about')
    ->image('https://example.com/hero.jpg');
```

---

`🔗` Meta tag helper
-------------------

[](#-meta-tag-helper)

```

    {!! Sitemap::meta() !!}

```

Outputs:

```

```

---

`🧪` Testing
-----------

[](#-testing)

```
vendor/bin/pest
```

SQLite must be enabled for in-memory testing.

---

📄 License
---------

[](#-license)

MIT © [VeiligLanceren.nl](https://veiliglanceren.nl)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance57

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

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

Recently: every ~18 days

Total

16

Last Release

298d ago

Major Versions

1.5.0 → 2.0.02025-05-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/22b99c08291f57985d16a87bcd5f1a3f4ae2e6332b5e04736b5bf4f0f91c3d19?d=identicon)[VeiligLanceren](/maintainers/VeiligLanceren)

---

Top Contributors

[![NielsHamelink-web](https://avatars.githubusercontent.com/u/67690385?v=4)](https://github.com/NielsHamelink-web "NielsHamelink-web (64 commits)")[![Shadow48402](https://avatars.githubusercontent.com/u/4586181?v=4)](https://github.com/Shadow48402 "Shadow48402 (6 commits)")

---

Tags

composer-packagegooglegoogle-searchgoogle-search-apilaravellaravel-12laravel-12-packagephp8seositemapsitemap-builderxmlxml-builder

###  Code Quality

TestsPest

### Embed Badge

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

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

###  Alternatives

[stillat/blade-parser

1451.2M12](/packages/stillat-blade-parser)[vtalbot/markdown

Markdown compiler for Laravel 5

100204.2k3](/packages/vtalbot-markdown)[olssonm/ampersand

Plug and play flat file markdown blog for your Laravel-projects

273.2k](/packages/olssonm-ampersand)

PHPackages © 2026

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