Adding Custom Exclusion Filters to SXA Sitemap
Introduction
Out of the box, SXA provides only the Change Frequency field to influence sitemap filtering and it’s a shared field that applies uniformly to all language versions. However, most projects have more nuanced scenarios where certain items should be excluded. This blog explains how to add custom exclusion filters to the SXA sitemap.
SXA sitemap filter
SXA uses the sitemap.filterItem pipeline to decide whether items should appear in the sitemap.
Each processor implements a Valid(FilterItemArgs args) check to include or exclude an item.
The out-of-the-box ChangeFrequency processor relies on a shared field, so its effect is the same for all languages. If you need per-language behavior, you should add a custom processor.
Custom filter
The class below extends FilterItemProcessor and excludes items based on three common SEO scenarios:
Excluding Fallback Items
Excluding Items that have a different Canonical Links
Exclude the items that are marked not to be indexed
public class SitemapCustomFilter : FilterItemProcessor
{
protected override bool Valid(FilterItemArgs args)
{
var item = args.Item;
var isFallbackItem = item.IsFallback;
var noIndex = item.Fields["robotsNoIndexNoFollow"];
var canonicalLink = item.Fields["canonicalLink"];
// Exclude from sitemap for fallback versions
if (isFallbackItem)
{
return false;
}
// Exclude from sitemap based on no index
if (noIndex != null && noIndex.Value == "1")
{
return false;
}
// Exclude from sitemap when canonical link is present
if (canonicalLink != null && !string.IsNullOrEmpty(canonicalLink.Value))
{
return false;
}
// add many Other Custom Rules
return true;
}
}
Registering the processor: Add the config under App_Config/Include so your processor runs in sitemap.filterItem. The example places your processor right after SXA’s ChangeFrequency processor.
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<sitemap.filterItem>
<processor
type="Customization.Pipelines.SitemapCustomFilter, Customization"
patch:after="processor[@type='Sitecore.XA.Foundation.SiteMetadata.Pipelines.Sitemap.FilterItem.ChangeFrequency, Sitecore.XA.Foundation.SiteMetadata']" />
</sitemap.filterItem>
</pipelines>
</sitecore>
</configuration>
How the Filter Works
Excludes fallback items via item.IsFallback to exclude items with fallback
Excludes items with a non-empty canonicalLink field, since they point to another canonical URL.
Checks the robotsNoIndexNoFollow field; if it’s set (value equals “1”), the item is excluded.
Deployment Checklist
Build and deploy Customization.dll to the bin folder.
Place the patch file under App_Config/Include/Customization.
Extending the filter for more scenarios
Exclude by template: check item.TemplateID
Exclude by path: check item.Paths.FullPath
Exclude by language: use args.Language for language-specific rules
Conclusion
With this custom filter in place, you can go beyond the shared Change Frequency behavior and tailor sitemap inclusion to match your SEO strategy and content governance.
Note: Though Sitecore recommends not to make customizations in XM cloud solution, until sitecore adds these filters out of the box this is the only option to add custom logic for filters.

