jgniecki/sitemap-bundle

Maintainers

👁 bubanga

Package info

github.com/jgniecki/SitemapBundle

Type:symfony-bundle

pkg:composer/jgniecki/sitemap-bundle

Statistics

Installs: 1 253

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.0 2025-09-04 09:54 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 2b922a5f802fee05f5ff9884cdcd3baf3841430c

This package is auto-updated.

Last update: 2026-06-04 13:14:15 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 hosts and groups

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

sitemap:
 default_priority: null
 default_changefreq: null
 hosts:
 default:
 path: '/sitemap.xml'
 groups:
 default:
 path: null
 lastmod: null
# main:
# path: '/sitemap.xml'
# host: 'example.(com|pl)'
# groups:
# default:
# path: '/sitemap-general.xml'
# blog:
# path: '/sitemap-blog.xml'

Each host can override the path for the sitemap index and the path and last modification date for its sitemap groups. When a host defines only the default group, the sitemap.hosts.<alias>.groups.default.path setting is ignored and a warning is triggered; use sitemap.hosts.<alias>.path instead.

Accessing the sitemap

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

License

This bundle is released under the MIT license.