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

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

mfonte/laravel-sitemap
======================

Laravel Sitemap Generator. Supports SitemapIndex, Images Sitemap and News Sitemap.

v1.3.1(1y ago)43.3k↓33.3%MITPHP

Since Jan 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mauriziofonte/laravel-sitemap)[ Packagist](https://packagist.org/packages/mfonte/laravel-sitemap)[ Docs](https://github.com/mauriziofonte/laravel-sitemap)[ RSS](/packages/mfonte-laravel-sitemap/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (11)Versions (11)Used By (0)

Generate sitemaps with Laravel (or for a Non-Laravel project), compatible with Images Sitemap and News Sitemap
==============================================================================================================

[](#generate-sitemaps-with-laravel-or-for-a-non-laravel-project-compatible-with-images-sitemap-and-news-sitemap)

[This package has been forked from spatie/laravel-sitemap](https://github.com/spatie/laravel-sitemap), to remove support for `SitemapGenerator`, remove installation requirement for PHP 8, and add support for **Images Sitemaps** and **News Sitemaps**.

Additionally, this package adds support for installation **outside a Laravel Project**. See **Using this package outside Laravel** section.

This package can generate a valid sitemap by writing your own custom logic for the sitemap structure, via the API provided by this package.

> Heads up! This package requires *Laravel 9* or *Laravel 10*For **PHP 7.4 and Laravel 8 compatibility** refer to **v1.1.\***

[![Latest Stable Version](https://camo.githubusercontent.com/47cf10fcc0e79e4d9717916b3956fadcb2d61cab858490a3c82522b0e2022ddc/68747470733a2f2f706f7365722e707567782e6f72672f6d666f6e74652f6c61726176656c2d736974656d61702f762f737461626c65)](https://packagist.org/packages/mfonte/laravel-sitemap)[![Total Downloads](https://camo.githubusercontent.com/1aab06294ac9b34e72524ad62c730719162cba0c18e8befac36d073bf1412cd6/68747470733a2f2f706f7365722e707567782e6f72672f6d666f6e74652f6c61726176656c2d736974656d61702f646f776e6c6f616473)](https://packagist.org/packages/mfonte/laravel-sitemap)[![Coverage Status](https://camo.githubusercontent.com/f1e4e2e58905ebb6cf1d33a370fe2850ea2fb9e0672fd00a2b302db1a68ca4b1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617572697a696f666f6e74652f6c61726176656c2d736974656d61702f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mauriziofonte/laravel-sitemap/)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9944bb508a192fabd664b2d19d67e6355b321e0c3afefe4f25748cb241acedf2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617572697a696f666f6e74652f6c61726176656c2d736974656d61702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mauriziofonte/laravel-sitemap/)

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

[](#installation)

For Laravel 9 or 10, or for a non-Laravel-based project running on **PHP &gt;= 8.0**

`composer require mfonte/laravel-sitemap`

For Laravel 8, or for a non-Laravel-based project running on **PHP &gt;= 7.4 &amp;&amp; &lt; 8.0**

`composer require mfonte/laravel-sitemap "^1.1"`

Creating sitemaps
-----------------

[](#creating-sitemaps)

You can only create your sitemap manually:

```
use Carbon\Carbon;
use Mfonte\Sitemap\Sitemap;
use Mfonte\Sitemap\Tags\Url;

Sitemap::create()
    ->add(
        Url::create('/home')
        ->setLastModificationDate(Carbon::yesterday())
        ->setChangeFrequency(Url::CHANGE_FREQUENCY_YEARLY)
        ->setPriority(0.1)
        ->addImage('/path/to/image', 'A wonderful Caption')
        ->addNews('A long story short', 'en', Carbon::yesterday(), 'Sitemaps are this great!')
    )
   ->add(...)
   ->writeToFile($path);
```

The sitemap generator can automatically understand what type of items you placed inside the sitemap, and create a valid schema accordingly. This is an example of a sitemap header with images and news:

```
\n

        http://localhost/page10\n
        2016-01-01T00:00:00+00:00
        daily
        0.8

            http://localhost/imageUrl

            2015-12-29
            defaultTitle

                defaultName
                defaultLanguage

```

You can also add your models directly by implementing the `\Mfonte\Sitemap\Contracts\Sitemapable` interface.

```
use Mfonte\Sitemap\Contracts\Sitemapable;
use Mfonte\Sitemap\Tags\Url;

class Post extends Model implements Sitemapable
{
    public function toSitemapTag(): Url | string | array
    {
        return route('blog.post.show', $this);
    }
}
```

Now you can add a single post model to the sitemap or even a whole collection.

```
use Mfonte\Sitemap\Sitemap;

Sitemap::create()
    ->add($post)
    ->add(Post::all());
```

This way you can add all your pages super fast without the need to crawl them all.

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

[](#creating-a-sitemap-index)

You can create a sitemap index:

```
use Mfonte\Sitemap\SitemapIndex;

SitemapIndex::create()
    ->add('/pages_sitemap.xml')
    ->add('/posts_sitemap.xml')
    ->writeToFile($sitemapIndexPath);
```

You can pass a `Mfonte\Sitemap\Tags\Sitemap` object to manually set the `lastModificationDate` property.

```
use Mfonte\Sitemap\SitemapIndex;
use Mfonte\Sitemap\Tags\Sitemap;

SitemapIndex::create()
    ->add('/pages_sitemap.xml')
    ->add(Sitemap::create('/posts_sitemap.xml')
        ->setLastModificationDate(Carbon::yesterday()))
    ->writeToFile($sitemapIndexPath);
```

the generated sitemap index will look similar to this:

```

      http://www.example.com/pages_sitemap.xml
      2016-01-01T00:00:00+00:00

      http://www.example.com/posts_sitemap.xml
      2015-12-31T00:00:00+00:00

```

Usage outside of Laravel
------------------------

[](#usage-outside-of-laravel)

The same instructions above apply, except for:

1. You **can not** use `Contracts\Sitemapable` to extend a *Model* (you're not on Laravel, aren't you?)
2. You **have to** use the `Sitemap::render()`, `Sitemap::writeToFile()`, `SitemapIndex::render()` and `SitemapIndex::writeToFile()` via providing the extra boolean flag `$nativeRenderer = true`
3. You **can not** use `Sitemap::writeToDisk()`, `Sitemap::toResponse()`, `SitemapIndex::writeToDisk()` and `SitemapIndex::toResponse()`

So, for example, a basic approach may be:

```
use Carbon\Carbon;
use Mfonte\Sitemap\Sitemap;
use Mfonte\Sitemap\Tags\Url;

$sitemapStream = Sitemap::create()->add(
    Url::create('/home')
        ->setLastModificationDate(Carbon::yesterday())
        ->setChangeFrequency(Url::CHANGE_FREQUENCY_YEARLY)
        ->setPriority(0.1)
        ->addImage('/path/to/image', 'A wonderful Caption')
        ->addNews('A long story short', 'en', Carbon::yesterday(), 'Sitemaps are this great!')
)
->add(...)
->render(nativeRenderer: true);
```

Changelog
---------

[](#changelog)

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

Testing
-------

[](#testing)

```
$ composer test
```

Credits
-------

[](#credits)

- [Original package published by Spatie](https://github.com/spatie/laravel-sitemap)
- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information. **This package has been forked from  and the relative license file has been migrated into this repository as-it-is**.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

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

Total

9

Last Release

620d ago

PHP version history (3 changes)v1.0PHP ^7.4

v1.1.1PHP &gt;=7.4

v1.2.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/7733524e324e4a6f68d80bad3cfc5737cda0bfb072154210de09c7c2820d070c?d=identicon)[mauriziofonte](/maintainers/mauriziofonte)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (174 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (26 commits)")[![mauriziofonte](https://avatars.githubusercontent.com/u/1758841?v=4)](https://github.com/mauriziofonte "mauriziofonte (11 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (7 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (7 commits)")[![ManuDoni](https://avatars.githubusercontent.com/u/10022459?v=4)](https://github.com/ManuDoni "ManuDoni (6 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (5 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (4 commits)")[![BrentRobert](https://avatars.githubusercontent.com/u/6866325?v=4)](https://github.com/BrentRobert "BrentRobert (3 commits)")[![emanuelmutschlechner](https://avatars.githubusercontent.com/u/27734375?v=4)](https://github.com/emanuelmutschlechner "emanuelmutschlechner (3 commits)")[![king724](https://avatars.githubusercontent.com/u/350488?v=4)](https://github.com/king724 "king724 (2 commits)")[![davidbonting](https://avatars.githubusercontent.com/u/6029739?v=4)](https://github.com/davidbonting "davidbonting (2 commits)")[![matt-daneshvar](https://avatars.githubusercontent.com/u/10030505?v=4)](https://github.com/matt-daneshvar "matt-daneshvar (1 commits)")[![aurawindsurfing](https://avatars.githubusercontent.com/u/14302496?v=4)](https://github.com/aurawindsurfing "aurawindsurfing (1 commits)")[![akoepcke](https://avatars.githubusercontent.com/u/5311185?v=4)](https://github.com/akoepcke "akoepcke (1 commits)")[![ousid](https://avatars.githubusercontent.com/u/21012933?v=4)](https://github.com/ousid "ousid (1 commits)")[![pascalbaljet](https://avatars.githubusercontent.com/u/8403149?v=4)](https://github.com/pascalbaljet "pascalbaljet (1 commits)")[![paulkned](https://avatars.githubusercontent.com/u/5045195?v=4)](https://github.com/paulkned "paulkned (1 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (1 commits)")[![RobLui](https://avatars.githubusercontent.com/u/10846766?v=4)](https://github.com/RobLui "RobLui (1 commits)")

---

Tags

image-sitemaplaravelnews-sitemapsitemaplaravel-sitemapgoogle image sitemapgoogle news sitemapgoogle sitemap index

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-sitemap

Create and generate sitemaps with ease

2.6k14.6M107](/packages/spatie-laravel-sitemap)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[nativephp/mobile

NativePHP for Mobile

82724.0k43](/packages/nativephp-mobile)[tonysm/importmap-laravel

Use ESM with importmap to manage modern JavaScript in Laravel without transpiling or bundling.

148399.8k1](/packages/tonysm-importmap-laravel)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[laracraft-tech/laravel-useful-additions

A collection of useful Laravel additions!

58109.4k](/packages/laracraft-tech-laravel-useful-additions)

PHPackages © 2026

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