esono/sitemap-bundle
Creates and updates sitemap files based on the current system contents
Requires
- chameleon-system/chameleon-base: ~7.1.0
- ext-curl: *
- ext-xmlwriter: *
README
Provides functionality to generate sitemap files via cronjob or console command. It is based on the current system contents: pages, products, categories, articles or any other custom content of the project. This cronjob also "pings" Google if it detects changes on the sitemaps. (https://developers.google.com/search/docs/advanced/sitemaps/build-sitemap#addsitemap)
Currently, only pages are supported out-of-the-box (by PageEntriesProvider).
If the page is restricted or contains "noindex" the page's robots configuration the page will not be considered.
Also only pages under activated navigations (tree nodes) will be considered.
The sitemaps can be reached with the URL /sitemap.xml for every enabled portal in every language.
Files are normally stored in PATH_CMS_CUSTOMER_DATA, but this can be configured.
Installation
Require it in composer.json and add the Bundle class to AppKernel.
Portals will have a new field Create sitemap. This is off by default.
To activate sitemap generation you have to enabled it for at least one portal.
Furthermore the navigations for a portal can in turn be deactivated for sitemap creation.
They will have the new field Consider for sitemap. It is on by default.
Configuration
Config options:
esono_sitemap:
path: 'path to xml'
max_urls_per_xml: 500
You can specify the target directory of the generated sitemap files with the config option:
The default is PATH_CMS_CUSTOMER_DATA/esono_sitemap/.
The subdirectory esono_sitemap is appended in any case
and under that more subdirectories as needed (for every portal/language).
During generation another temporary directory is also created in that path (ie. PATH_CMS_CUSTOMER_DATA).
The files there are however served by a controller starting with the URL <domain>/sitemap.xml as a sitemap must be top-level.
Extending
Any custom content of a project that is no regular page (e. g. a number of manufacturers added as route collection)
can be provided with tagging a service with esono_sitemap.entry_provider and implementing the interface
SitemapEntryProviderInterface.
These providers are called once for every portal (active for sitemap) and every language of that portal.
Usage
There is a cronjob called "Update Sitemap-Data" (DE: "Sitemap-Daten aktualisieren"). Additionally there is a console command to start the sitemap generation.
./app/console esono:sitemap:generate
Restrictions
lastmod, changefreq and priority are supported if a custom SitemapEntryProviderInterface fills those fields in the data model.
Language alternatives to a page are currently not included in the sitemap. Please make sure, that you define these in your
<head /> tag (using <link rel="alternate" hreflang="lang_code" href="url_of_page" />) of each html page that has URLs for alternative languages.