Custom root specific sitemap generators | Community
Skip to main content
May 19, 2025

Custom root specific sitemap generators

  • May 19, 2025
  • 4 replies
  • 1031 views

There  are custom sitemap generators in our codebase created by extending ResourceTreeSItemapGenerator, Is it register these two services according to specific rootpath.

I have tried with sitemap_root property but it doesnt work

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

4 replies

Karishma_begumSh
May 19, 2025

Hi @tanuj05 You need to use OSGi config for SitemapGeneratorManager to map your generator to a root path.

Add property to your generator 
@Component(
service = { SitemapGenerator.class },
property = {
SitemapGenerator.PROPERTY_NAME + "=customGenerator"
}
)
public class CustomSitemapGenerator extends ResourceTreeSitemapGenerator {
// Your logic
}
property name resolves to
public static final String PROPERTY_NAME = "sling.sitemap.generator.name";

Create this config in your ui.config module:
/apps/your-project/osgiconfig/config.publish/com.adobe.cq.wcm.core.extensions.sitemap.SitemapGeneratorManager~customGenerator.cfg.json

JSON CONTENT:
{
"generatorName": "customGenerator",
"rootPaths": [
"/content/sitea"
]
}


tanuj05Author
May 19, 2025

/apps/your-project/osgiconfig/config.publish/com.adobe.cq.wcm.core.extensions.sitemap.SitemapGeneratorManager~customGenerator.cfg.json
I check this osgi config there is only field , which is a checkbox for "on-demand"

tanuj05Author
May 19, 2025

 

narendragandhi
Community Advisor
Community Advisor
May 19, 2025

Hi @tanuj05 

 

The root path is specified by selecting it under page properties for the root path. If there are multiple then you can select at all those paths. I would recommend to follow the steps as mentioned here.- https://www.theaemmaven.com/post/aem-apache-sling-sitemap

 

Hope this helps and let us know for any issues.

 

Thanks

Narendra

AmitVishwakarma
Community Advisor
Community Advisor
May 20, 2025

Hi @tanuj05 ,

Try below solution:

 

1. Custom Sitemap Generator Java Class

package com.myproject.core.sitemap; import com.adobe.cq.wcm.core.extensions.sitemap.ResourceTreeSitemapGenerator; import com.adobe.cq.wcm.core.extensions.sitemap.SitemapGenerator; import org.osgi.service.component.annotations.Component; @Component( service = { SitemapGenerator.class }, property = { SitemapGenerator.PROPERTY_NAME + "=customGenerator" } ) public class CustomSitemapGenerator extends ResourceTreeSitemapGenerator { // Optional: Override methods if you need custom logic }

2. OSGi Config for Generator Manager

In your ui.config module, add this file:

ui.config/src/main/content/jcr_root/apps/yourproject/osgiconfig/config.publish/com.adobe.cq.wcm.core.extensions.sitemap.SitemapGeneratorManager~customGenerator.cfg.json

Make sure the filename matches the generator name after the ~ (tilde).

{ "generatorName": "customGenerator", "rootPaths": [ "/content/sitea" ], "onDemand": false }

 

Imran__Khan
Community Advisor
Community Advisor
May 20, 2025
kautuk_sahni
Community Manager
Community Manager
June 26, 2025

@tanuj05 Just checking in — were you able to resolve your issue?
We’d love to hear how things worked out. If the suggestions above helped, marking a response as correct can guide others with similar questions. And if you found another solution, feel free to share it — your insights could really benefit the community. Thanks again for being part of the conversation!

Kautuk Sahni