Download the PHP package werkspot/sitemap-bundle without Composer
On this page you can find all versions of the php package werkspot/sitemap-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package sitemap-bundle
Werkspot sitemap bundle
Bundle for generating dynamic sitemap.xml content with support for multiple sections and pages per section.
Install
# composer require werkspot/sitemap-bundle
Update your routing
That will make the bundle listen to /sitemap.xml
, /sitemap.{section}.xml
and /sitemap.{section}.{page}.xml
Usage
The bundle generates a sitemap by looking for data providers.
A provider is a class that implements ProviderInterface and is tagged as werkspot.sitemap_provider
in the service container.
The bundle's service will gather data from all providers and create a sitemap section for everyone of them.
Each section can generate one or more pages.
Single page provider
To facilitate sitemap creation for static lists things or pages that do not need to be created dynamically AbstractSinglePageSitemapProvider can be extended. That will only require providing a section name and a SitemapSectionPage with Url objects.
Example
This will generate /sitemap.default.xml
with 3 pages and put a link to it in /sitemap.xml
Multiple page provider
A more complex provider can extend AbstractSitemapProvider. In that case the provider can select how many pages it wants to generate and what results to return in every page.
Example
The following will generate /sitemap.products.xml
and if the count is too high it will split in multiple pages: /sitemap.products.1.xml
, /sitemap.products.2.xml
etc and put all the right links to these in /sitemap.xml
for indexing to happen.
Adding alternate language pages
To add links to translations for pages to the sitemap, you can use AlternateLink
and add these to a Url.
Google Guidelines: https://support.google.com/webmasters/answer/2620865?hl=en
Note: The alternate links should include the Url itself, see the second note in the link above