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
Topics help categorize Community content and increase your ability to discover relevant content.
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"
]
}
/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"
Views
Replies
Total Likes
Views
Replies
Total Likes
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.
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
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
@tanuj05 Follow below link
https://medium.com/@toimrank/aem-sitemap-creation-4877b3a8391a
Views
Likes
Replies
Views
Likes
Replies