Expand my Community achievements bar.

Introducing Adobe LLM Optimizer: Own your brand’s presence in AI-Powered search and discovery

Custom root specific sitemap generators

Avatar

Level 1

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

tanuj05_0-1747631699817.png

I have tried with sitemap_root property but it doesnt work

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

7 Replies

Avatar

Level 2

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"
]
}


Avatar

Level 1

/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"

Avatar

Level 1

tanuj05_0-1747648687887.png

 

Avatar

Level 2

You should not edit the default config via webconsole but create a config like this

/apps/your-project/osgiconfig/config.publish/com.adobe.cq.wcm.core.extensions.sitemap.SitemapGeneratorManager~customGenerator.cfg.json

try changing your json
{
"generatorName": "customGenerator",
"rootPaths": [
"/content/sitea"
],
"onDemand": false
}
and also make sure
Make sure your page has sling:sitemapRoot=true.

Avatar

Community Advisor

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

Avatar

Community Advisor

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
}

 

Avatar

Community Advisor