Skip to main content

Technical reference

The Sitemap plugin generates XML sitemaps for published Brightspot content. It supports standard, news, and video sitemap types, manages sitemap generation through configurable background tasks, and organizes output into partitions to keep individual files within search-engine size limits.

Installation

Requirements
Requires Brightspot 4.5 or later.
<dependency>
<groupId>com.brightspot.sitemap</groupId>
<artifactId>sitemap</artifactId>
<version>1.0.1</version>
</dependency>

API reference

Content type interfaces

To include a content type in a sitemap, implement the appropriate interface on any class that also extends Content and implements Directory.Item.

InterfaceMethodDescription
SiteMapItemgetSiteMapEntries(Site site)Returns entries for the standard sitemap.
NewsSiteMapItemgetNewsSiteMapEntries(Site site)Returns entries for the news sitemap (news-sitemap.xml).
VideoSiteMapItemgetSiteMapEntries(Site site)Returns entries for the video sitemap (video-sitemap.xml).

All three extend GlobalSiteMapItem, which extends Recordable.

SiteMapEntry

SiteMapEntry represents a single <url> element in the sitemap XML. Return one per URL the content type resolves to across all sites.

MethodTypeRequiredDescription
setPermalink(String)StringYesFull URL, including protocol and domain. Non-ASCII characters are percent-encoded automatically.
setUpdateDate(Date)DateNoLast-modified date. Maps to <lastmod>.
setChangeFrequency(SiteMapChangeFrequency)enumNoHint to search engines about how often the URL changes. Maps to <changefreq>.
setPriority(Double)DoubleNoRelative priority within the site, from 0.0 to 1.0. Maps to <priority>.
setImages(List<SiteMapImage>)ListNoImage extension data. Maps to <image:image> elements.
setVideos(List<SiteMapVideo>)ListNoVideo extension data. Maps to <video:video> elements.
setNews(List<SiteMapNews>)ListNoNews extension data. Maps to <news:news> elements.

SiteMapChangeFrequency

ValueDescription
ALWAYSContent changes every time it is accessed.
HOURLYContent changes approximately every hour.
DAILYContent changes approximately once a day.
WEEKLYContent changes approximately once a week.
MONTHLYContent changes approximately once a month.
YEARLYContent changes approximately once a year.
NEVERArchived content that will not change.

SiteMapImage

Attach one or more SiteMapImage instances to a SiteMapEntry to populate <image:image> elements.

MethodTypeRequiredDescription
setUrl(String)StringYesFull URL to the image.
setTitle(String)StringNoImage title.
setCaption(String)StringNoImage caption.
setGeoLocation(String)StringNoGeographic location where the image was taken.
setLicense(String)StringNoURL of the image license.

SiteMapVideo

Attach one or more SiteMapVideo instances to a SiteMapEntry to populate <video:video> elements.

MethodTypeRequiredDescription
setThumbnailLoc(String)StringYesURL to the video thumbnail image.
setTitle(String)StringYesVideo title.
setDescription(String)StringYesVideo description.
setContentLoc(String)StringNoDirect URL to the video file. Either contentLoc or playerLoc must be set.
setPlayerLoc(String)StringNoURL of the video player page. Either contentLoc or playerLoc must be set.
setPlayerLocAllowEmbed(Boolean)BooleanNoWhether the player can be embedded on other pages.
setPlayerLocAutoplay(String)StringNoAutoplay parameter appended to the player URL.
setDuration(Long)LongNoDuration in seconds.
setExpirationDate(Date)DateNoDate after which the video is no longer available.
setRating(Double)DoubleNoRating from 0.0 to 5.0.
setViewCount(Long)LongNoNumber of views.
setPublicationDate(Date)DateNoDate the video was first published.
setTags(List<String>)ListNoDescriptive tags for the video.
setCategory(String)StringNoSingle category describing the video's topic.
setFamilyFriendly(Boolean)BooleanNoWhether the video is suitable for all audiences.
setRestriction(String)StringNoSpace-delimited ISO 3166 country codes. Use with setRestrictionRelationship.
setRestrictionRelationship(SiteMapRelationship)enumNoWhether the restriction list is an allowlist or a blocklist.
setGalleryLoc(String)StringNoURL of a gallery page associated with the video.
setGalleryLocTitle(String)StringNoTitle of the gallery page.
setPrice(Double)DoubleNoPrice to view the video. Use with setPriceCurrency.
setPriceCurrency(String)StringNoISO 4217 currency code for the price (for example, USD).
setRequiresSubscription(Boolean)BooleanNoWhether viewing requires a subscription.
setUploader(String)StringNoDisplay name of the video uploader.
setUploaderInfo(String)StringNoURL with more information about the uploader.
setLive(Boolean)BooleanNoWhether the video is a live stream.

SiteMapRelationship

Used with SiteMapVideo#setRestrictionRelationship(SiteMapRelationship).

ValueDescription
ALLOWVideo is available only in the specified countries.
DENYVideo is not available in the specified countries.

SiteMapNews

Attach a SiteMapNews instance to a SiteMapEntry to populate <news:news> elements.

MethodTypeRequiredDescription
setName(String)StringYesPublication name. Maps to <news:publication><news:name>.
setLanguage(String)StringYesBCP 47 language code (for example, en). Maps to <news:publication><news:language>.
setPublicationDate(Date)DateYesDate the article was published. Maps to <news:publication_date>.
setTitle(String)StringYesArticle title. Maps to <news:title>.
setGenres(List<String>)ListNoPublication genres (for example, Blog, Opinion). Rendered as a comma-delimited value in <news:genres>.
setGeoLocations(String)StringNoGeographic locations the article relates to. Maps to <news:geo_locations>.
setKeywords(List<String>)ListNoKeywords describing the topic. Rendered as a comma-delimited value in <news:keywords>.
setStockTickers(List<String>)ListNoStock tickers referenced in the article. Rendered as a comma-delimited value in <news:stock_tickers>.

SiteMapConfig

SiteMapConfig controls how the sitemap background tasks run. The plugin discovers a concrete implementation at run time using ClassFinder. Implement this interface to customize task scheduling, content age limits, partition strategies, or file size constraints.

MethodDefaultDescription
isAllowedToRun()Required. Return true only on the designated task host. As a best practice, call TaskUtils.isRunningOnTaskHost().
getSiteMapTypes(Site site)Required. Return the SiteMapType instances to enable for the given site.
getMaximumContentAgeDays(Site, SiteMapType<?>)type defaultMaximum age of content included in partitioned sitemaps.
getMaximumLatestContentAgeDays(Site, SiteMapType<?>)type defaultMaximum age of content included in the dynamic sitemap-latest.xml file.
getPartitionStrategy(Site, SiteMapType<?>)type defaultPartition strategy to use for the given site and type.
getMaximumSiteMapEntries()50000Maximum number of <url> elements per sitemap file.
getMaximumLatestSiteMapEntries()1000Maximum entries in the sitemap-latest.xml file.
getMaximumSiteMapFileSize()10485760Maximum file size in bytes (10 MB).
shouldRepartition(SiteMapPartitionConfiguration)hourlyReturn true when partitions should be reconfigured.
getFetchSize()400Query fetch size for sitemap content queries. Override the default via the setting key cms/siteMap/queryOptionsFetchSize.
shouldFormatXml()trueWhether to format generated XML with indentation.

SiteMapType

SiteMapType<T> defines a category of sitemap and maps content types to sitemap entries. Implement this interface to create a custom sitemap type beyond the three built-in types.

MethodDefaultDescription
getPrefix()Required. File name prefix. An empty string produces sitemap.xml; "news-" produces news-sitemap.xml. Each implementation must use a unique prefix.
getSiteMapItemClass()Required. The content type interface this sitemap type handles.
getEntries(T item, Site site)Required. Returns the sitemap entries for a given item and site.
getSitemapItemQuery()Query.from(getSiteMapItemClass()).where("* matches *")Query used to retrieve all sitemap candidates.
updateSiteMapMap(Map<String, Object>)no-opHook to inject XML namespace declarations into the root sitemap element.
getDefaultMaximumContentAgeDays()7300 (~20 years)Maximum age of content included in this sitemap type.
getDefaultMaximumLatestContentAgeDays()2Maximum age of content included in sitemap-latest.xml.
getLabel()derived from class nameDisplay name for the sitemap type.
getPartitionStrategy()YearMonthPartitionStrategyDefault partition strategy for this type.

PartitionStrategy

PartitionStrategy controls how the sitemap task divides content across sitemap files and determines when each file needs to be regenerated. Implement this interface to create a custom partitioning scheme.

MethodDescription
updatePartitions(SiteMapConfig, Site, SiteMapType<?>)Required. Create, update, or delete SiteMapPartition records for the given site and type.
shouldUpdateSitemap(SiteMapConfig, Site, SiteMapType<?>, SiteMapPartition)Required. Return true when the sitemap for the given partition needs to be regenerated.
partitionContentQuery(SiteMapConfig, Site, SiteMapType<T>, SiteMapPartition)Required. Return the content query scoped to a specific partition.
latestContentQuery(SiteMapConfig, Site, SiteMapType<T>, SiteMapPartition)Returns a query for content published more recently than the partition's last successful run, up to getMaximumLatestContentAgeDays. Has a default implementation.

Built-in implementations

Sitemap types

ClassPrefixContent interfaceDefault max content age
StandardSiteMapType""SiteMapItem~20 years
NewsSiteMapType"news-"NewsSiteMapItem2 days
VideoSiteMapType"video-"VideoSiteMapItem~20 years

Partition strategies

YearMonthPartitionStrategy organizes content into monthly buckets based on publication date. It creates one SiteMapPartition per year-month combination in which published content exists, and determines regeneration frequency by partition age.

Partition ageRegeneration frequency
Within the last monthDaily
One to six months oldWeekly
Six months to two years oldMonthly
Older than two yearsEvery 180 days

SinglePartitionStrategy maintains a single partition regardless of content volume, regenerating it every six hours. It is used by NewsSiteMapType to keep news sitemaps current.

Was this page helpful?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.