Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



28 Commits

Repository files navigation

Fork CMS Sitemaps module

The Sitemaps module lets you automatically generate a sitemapindex and all its sitemaps.



  • Creates a sitemap.xml and a file per sitemap-provider (like f.e.: Pages, Blog, Realizations, Jobs, ...).
  • You can easily add custom modules to the sitemap generator.
  • There is a re-generate button in the backend, so you can regenerate all sitemaps.


  • Execute composer require jeroendesloovere/sitemap-bundle
  • Then copy/paste this module to your fork cms.
  • Add in app/AppKernel:
new \Backend\Modules\Sitemaps\Sitemaps(),
new \JeroenDesloovere\SitemapBundle\SitemapBundle(),
  • Install the module.
  • Add in .gitignore:
  • Add in .htaccess:
# allow sitemaps
RewriteRule ^sitemap.xml$ - [L]
RewriteRule ^sitemap_(.*).xml$ - [L]
  • Add in composer.json for post-update-cmd:
"php bin/console sitemap:generate"
  • If you are using capistrano to deploy, add the following to deploy.rb:
## Generate sitemap
namespace :sitemap do
  desc "Generate the sitemap.xml and sitemap files per provider."
  task :generate do
    on roles(:db) do
      execute "cd #{current_path} && bin/console sitemap:generate"

before "deploy:cleanup", "sitemap:generate"
after "deploy:rollback", "sitemap:generate"

Example: "How to create your custom sitemap?"

We need to notify Symfony that we have a new sitemap provider. Add the following somewhere in your services.yaml

            - { name: sitemap.provider }

When the SitemapGenerator needs to generate the sitemap(s), it will ask all SitemapProviders to fill in the items. Create something like the following in your app.


namespace App\SitemapProviders;

use JeroenDesloovere\SitemapBundle\Item\ChangeFrequency;
use JeroenDesloovere\SitemapBundle\Provider\SitemapProvider;
use JeroenDesloovere\SitemapBundle\Provider\SitemapProviderInterface;

class NewsArticleSitemapProvider extends SitemapProvider implements SitemapProviderInterface
    /** @var NewsArticleRepository */
    private $articleRepository;

    public function __construct(NewsArticleRepository $articleRepository)
        $this->articleRepository = $articleRepository;

        // `NewsArticle::class` would even be better then just `NewsArticle`
        // because you can then use it with doctrine events.

    public function createItems(): void
        /** @var Article[] $articles */
        $articles = $this->articleRepository->findAll();
        foreach ($articles as $article) {
            $this->createItem('/nl/xxx/url-to-article', $article->getEditedOn(), ChangeFrequency::monthly());

View more examples over here

How to generate the sitemaps?

You can now generate the sitemap(s) by executing:

bin/console sitemap:generate

Use a cronjob (f.e. every hour) to have up-to-date sitemaps.

OR if you want to use PHP



It would be great if you could help us improve the module. GitHub does a great job in managing collaboration by providing different tools, the only thing you need is a GitHub login.

  • Use Pull requests to add or update code
  • Issues for bug reporting or code discussions

More info on how to work with GitHub on


The module is licensed under MIT. In short, this license allows you to do everything as long as the copyright statement stays present.