Sitemaps | Version 3

Add-on Sitemaps: Documentation

Learn how to administrate the Sophora Sitemaps Add-on to generate sitemaps protocol complient xml for search engine optimization.

Archived documentation for Sophora 3. End-of-support date for this version: 7/25/21

Documentation for Sophora 4

Sitemaps protocol

The open sitemaps protocol ( is a human and machine readable xml interface to describe the structure of a website. The sitemaps standard enables search engines to read and understand a website. Doing so will greatly improve your SEO, as all modern search engines understand the sitemaps protocol. The Sophora Sitemaps add-on supports version 0.90 of the protocol. It is able to automatically generate the xml based on your website structure and by using customizable mapping classes in Java to provide meta data.

Google extensions

In addition to the open sitemaps standard, this addon supports the google extensions for news (version 0.9), images (version 1.1) and videos (version 1.1). These sitemap extensions and follow-up links are explained at the google support pages (

Sitemap-XML containing these extensions looks like this:


Project Setup

The Sophora Sitemaps add-on is a separate maven dependency for your delivery. Installing the add-on provides you with the new Sitemaps servlet, which then has to be added to your web.xml and templates.xml.

Maven dependency: pom.xml


Servlet mapping: web.xml


Sophora template mapping: templates.xml

<nodetype name="sophora-nt:structureNode">
		<template type="sitemap">/system/servlet/sitemap.servlet</template> 

Preparing a Solr Core

This addon generates the entries for your sitemap by reading all relevant documents from a specific solr core. Specific converters are used to create those entries from solr documents. Technically any solr core will do for this purpose, but we recommend using a dedicated solr core just containing the documents you want to have in your sitemap.

Custom Sophora Sitemap mapping classes

To use custom Sophora Sitemap mapping classes you need to implement the interface. The class should be located in the package specified by the property

The Mapperfactory has two main purposes:

  1. It defines from which solr core the documents should be read to convert them to entries in your Sitemap
  2. It provides your mapper implementations. There are four mappers to provide. Three for the google extensions for news, video and image and one for all the other documents.

Each mapper is then used to provide properties based on a solr document. Based on the mapping the xml will be generated. For convenience it is possible to use the class:

public class CustomUrlMapper extends AbstractMapper implements IUrlMapper {

	public static final String SOLR_FIELD_URL = "url_s";
	public static final String SOLR_FIELD_LAST_MOD = "sophora_modificationDate_dt";

	public DefaultUrlMapper(Map<String, Object> solrDocument) {

	public boolean isApplicable() {
		return true;

	public String getLocation() {
		return Objects.toString(getSolrDocument().get(SOLR_FIELD_URL));

	public DateTime getLastMod() {
		return parseDate(getSolrDocument(), SOLR_FIELD_LAST_MOD);

	public ChangeFreq getChangefreq() {
		return ChangeFreq.DAILY;

	public BigDecimal getPriority() {
		return null;

There is a DefaultMapperFactory providing DefaultMapper-Implementations.

Properly writing custom mappers

For every solr document there should be only one mapper implementation that is applicable. The easiest way to achive this is by making a clear distinction by the solr documents nodetype. The default implementation for example always create default URL-entries and never any google extensions.

Generating the sitemap xml

After configuring the add-on as described above, visiting an index document using the template type "sitemap" creates the sitemap index and returnes the link to the generated sitemap xml.


If caching is enabled using the Sophora property the sitemap xml cache will periodically update. The update interval is configurable via


This add-on supports paging using the url parameter p. A typical url with paging looks like this (Here, the fourth page at index 3 is used):


PropertyDescription Java package to search the implementation of the IMapperFactory in. (Default: interval in minutes to invalidate and regenerate the xml. (Default: 30) set to true the xml output will be formatted. Otherwise the xml will be displayed in one line. (Default: true) property controls which namespace-declarations to write at the start of the generated XML-File. You can use it to filter out the namespace declarations for google's sitemap extensions. Possible values are:
  • news (
  • video (
  • image (
You can use several values separated by a comma. The default is news,image,video.
You should not use this unless you have custom mapper classes for any of those types that never generates entries (thus their method isApplicable always returns false).
The namespace-declaration for the sitemaps standard however is always written and not affected by this property.

Last modified on 10/8/19

The content of this page is licensed under the CC BY 4.0 License. Code samples are licensed under the MIT License.