Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Customizing AEM's OOTB Sitemap to include new attributes in AEMaaCs

Avatar

Level 4

We have custimized the AEM's OOTB sitemap by creating new service by extending the ResourceTreeSiteMapGenerator and 

overriding addResource() method there. In that service method, I am able to successfully modify the URL and lastModified values. But I have additional requirements to add new attributes in the sitemap (highlighted in blue color). I found that, there is no direct way to do that in the service. I think we can do builder-like API support for these custom extensions which is like creating a few interfaces and classes (just to include a few attributes there). Can somebody confirm if there is any other way?

 

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
 
<url>
   
<loc>http://www.xyz.org/abc/a1.html</loc>
   
<data:news>
   
<news:author>
     
<news:title>The Example Times</news:name>
     
<news:language>en</news:language>
   
</news:author>
  </data:news>

 
</url>
</urlset>

 

@component(service = SitemapGenerator.class)
@ServiceRanking(100)
public class NewsSiteMap extends ResourceTreeSitemapGenerator {
 
    protected void addResource(final String name, final Sitemap sitemap, final Resource resource)
            throws
            SitemapException {
 
1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

hi @karanmahi , you are right, there is no ootb configuration available for the sitemap service to modify the sitemap as you have mentioned above. To achieve this, you have to add your own logic in the extended class and use builder API to for the content.

View solution in original post

1 Reply

Avatar

Correct answer by
Employee Advisor

hi @karanmahi , you are right, there is no ootb configuration available for the sitemap service to modify the sitemap as you have mentioned above. To achieve this, you have to add your own logic in the extended class and use builder API to for the content.