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
}
3. Mark the Page as a Sitemap Root
Your root page /content/sitea must have this property:
You can:
- Add it using editable template structure
- Add it to page properties dialog
- Or set it via code (recommended for AEMaaCS)
4. Validate After Deployment
After Cloud Manager deployment:
- Hit the URL:
https://<publish-domain>/content/sitea.sitemap.xml
Logs should show your generator being used:
Using sitemap generator: customGenerator for root: /content/sitea
On-Demand Trigger (Only if onDemand=true)
If you set "onDemand": true, then you must trigger the sitemap like this:
POST https://<publish-domain>/content/sitea.sitemap.xml
Make sure permissions allow it (via dispatcher and ACLs).
Regards,
Amit