nik/laravel-sitemap

Laravel Sitemap package for Laravel.

Maintainers

Package info

github.com/Nikhilchudasama/sitemap

pkg:composer/nik/laravel-sitemap

Statistics

Installs: 50

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

9.0.1 2026-05-15 04:51 UTC

This package is auto-updated.

Last update: 2026-05-15 04:55:53 UTC


README

Total Downloads License

A powerful and easy-to-use sitemap generator for Laravel. Support for Google News, Images, Videos, and Multilingual sitemaps.

Features

  • Supports Laravel 10, 11, 12, and 13.
  • PHP 8.2+ Compatibility.
  • Dynamic sitemap generation.
  • Automatic caching.
  • Support for Big Sitemaps (Sitemap Index).
  • Google News, Images, Videos, and Multilingual support.
  • Multiple output formats (XML, HTML, TXT).

Installation

Install the package via composer:

composer require nik/laravel-sitemap

(Optional) Publish the configuration file and views:

php artisan vendor:publish --provider="Nik\Sitemap\SitemapServiceProvider"

Quick Start

Generate a simple sitemap in your routes/web.php:

use Nik\Sitemap\Sitemap;

Route::get('sitemap.xml', function () {
    /** @var Sitemap $sitemap */
    $sitemap = app('sitemap');

    // Add static pages
    $sitemap->add(url('/'), now(), '1.0', 'daily');
    $sitemap->add(url('contact'), now(), '0.7', 'monthly');

    // Add dynamic items from database
    $posts = \App\Models\Post::latest()->get();
    foreach ($posts as $post) {
        $sitemap->add(url($post->slug), $post->updated_at, '0.9', 'weekly');
    }

    return $sitemap->render('xml');
});

Advanced Usage

For more detailed examples, please refer to the EXAMPLES.md file.

Common Scenarios:

License

This package is open-sourced software licensed under the MIT license.