jgniecki/sitemap-bundle

Installs: 456

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:symfony-bundle

v1.0.1 2025-07-17 12:19 UTC

This package is auto-updated.

Last update: 2025-07-18 16:03:16 UTC


README

SitemapBundle provides a simple way to generate XML sitemaps for Symfony applications using PHP attributes.

Installation

composer require jgniecki/sitemap-bundle

After the bundle is installed, run the install command to copy the default configuration and route setup into your project:

php bin/console sitemap:install

This command will create the following files if they do not already exist:

  • config/packages/sitemap.yaml – default bundle configuration with group definitions.
  • config/routes/sitemap.yaml – imports the sitemap route loader.

Usage

Annotate your controllers or actions with the #[Sitemap] attribute to include routes in the sitemap:

use jgniecki\SitemapBundle\Sitemap\Attribute\Sitemap;
use jgniecki\SitemapBundle\Sitemap\Enum\ChangeFreqEnum;
use Symfony\Component\Routing\Attribute\Route;

#[Sitemap(priority: 1.0, changefreq: ChangeFreqEnum::DAILY)]
#[Route('/', name: 'homepage')]
public function index(): Response
{
    // ...
}

Configure groups

You can define sitemap groups in config/packages/sitemap.yaml. A default configuration is generated by the install command:

sitemap:
    default_priority: null
    default_changefreq: null
    groups:
        default:
            path: '/sitemap-default.xml'
            lastmod: null
#        custom:
#          lastmod: 'now'

Each group can override the path and last modification date for its sitemap.

Accessing the sitemap

The bundle registers routes for your sitemaps automatically. Visit /sitemap.xml to see the sitemap index when multiple groups are configured. The default group's sitemap is available under the path defined in sitemap.groups.default.path.

License

This bundle is released under the MIT license.