While working a website on AEM 6.5 (SP 6.5.19) ,
We have the default Sitemap working as https://domain.com/sitemap.xml
A requirement was to create custom sitemap url's and not the default ones as:
https://domain.com/sitemap-cards.xml (show all pages from the path https://domain.com/cards.html )
and
https://domain.com/sitemap-resources.xml (show all pages from the path https://domain.com/resources.html )
How can we do this? May be not a sitemap but create a separate page/component and render output as xml?
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
@surenk - Have you checked video on this page https://experienceleague.adobe.com/en/docs/experience-manager-learn/sites/seo/sitemaps which defines setting sitemap at different paths? This can be done using AEM's OOTB sitemap generator and as mentioned here https://github.com/apache/sling-org-apache-sling-sitemap?tab=readme-ov-file#content-model you need to set sling:sitemapRoot = true for /cards and /resources pages from page properties.
By using AEM OOTB's sitemap, you adhere to sitemap's schema and it takes care of generating the index files which will be used by search engines.
If you have enabled sling:sitemapRoot = true on
/content/project/us
/content/project/us/cards
/content/project/us/resources
Now when you open index file https://domain.com/content/project/us.sitemap-index.xml it will give you something like this
<sitemap>
https://domain.com/content/project/us.sitemap.xml
</sitemap>
<sitemap>
https://domain.com/content/project/us.sitemap.cards-sitemap.xml
</sitemap>
<sitemap>
https://domain.com/content/project/us.sitemap.resources-sitemap.xml
</sitemap>
If the sitemap urls e.g. https://domain.com/content/project/us.sitemap.cards-sitemap.xml doesn't meet your need, you can see if you can rewrite the urls based on some logic.
If this still doesn't work then you can go for custom sitemap generater based on your own logic in AEM as briefly described here https://www.albinsblog.com/2017/03/how-to-generate-sitemap-for-multi-site-environments-cq5-aem.html
@surenk - Have you checked video on this page https://experienceleague.adobe.com/en/docs/experience-manager-learn/sites/seo/sitemaps which defines setting sitemap at different paths? This can be done using AEM's OOTB sitemap generator and as mentioned here https://github.com/apache/sling-org-apache-sling-sitemap?tab=readme-ov-file#content-model you need to set sling:sitemapRoot = true for /cards and /resources pages from page properties.
By using AEM OOTB's sitemap, you adhere to sitemap's schema and it takes care of generating the index files which will be used by search engines.
If you have enabled sling:sitemapRoot = true on
/content/project/us
/content/project/us/cards
/content/project/us/resources
Now when you open index file https://domain.com/content/project/us.sitemap-index.xml it will give you something like this
<sitemap>
https://domain.com/content/project/us.sitemap.xml
</sitemap>
<sitemap>
https://domain.com/content/project/us.sitemap.cards-sitemap.xml
</sitemap>
<sitemap>
https://domain.com/content/project/us.sitemap.resources-sitemap.xml
</sitemap>
If the sitemap urls e.g. https://domain.com/content/project/us.sitemap.cards-sitemap.xml doesn't meet your need, you can see if you can rewrite the urls based on some logic.
If this still doesn't work then you can go for custom sitemap generater based on your own logic in AEM as briefly described here https://www.albinsblog.com/2017/03/how-to-generate-sitemap-for-multi-site-environments-cq5-aem.html
Thank you @Jineet_Vora @EstebanBustamante will try the suggestions and update here.
Hi,
You have a good explanation of how this works, and even an example of how to customize (create your own) sitemap based in your requirements in this article: https://www.theaemmaven.com/post/aem-apache-sling-sitemap
Hope this helps
Hi @surenk ,
You can create custom sitemap URLs in Adobe Experience Manager (AEM) by creating custom servlets or scripts to generate XML content for the desired URLs. Here's a high-level approach to achieve this:
Create a Servlet or Script: You can create a custom servlet or script in your AEM project to generate the XML content for your custom sitemap URLs. This servlet or script will be responsible for querying the content from the specified paths (/cards.html and /resources.html) and formatting it into XML format.
Map URLs to Servlet or Script: Once you have created the servlet or script, you need to map the custom sitemap URLs (/sitemap-cards.xml and /sitemap-resources.xml) to your servlet or script in the AEM dispatcher configuration or using the Apache Sling Resource Resolver configuration.
Query Content: Within your servlet or script, use the AEM QueryBuilder API or other appropriate methods to query the content from the specified paths (/cards.html and /resources.html). Retrieve the necessary properties or information for each page that you want to include in the sitemap.
Generate XML: Once you have queried the content, format the retrieved information into XML format according to the sitemap protocol. Include relevant information such as URL, last modification date, change frequency, and priority for each page.
Render XML Output: Render the generated XML content as the response from your servlet or script when the custom sitemap URLs are accessed. Ensure that the content is properly formatted and adheres to the sitemap protocol standards.
Testing and Validation: Test your custom sitemap URLs to ensure that they are accessible and return the expected XML content. Validate the generated XML against the sitemap protocol standards to ensure compliance.
By following these steps, you can create custom sitemap URLs in AEM and generate XML content for those URLs based on specific paths or criteria. This approach allows you to meet your requirements for custom sitemap URLs while leveraging the flexibility and extensibility of AEM's servlets and scripts.
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies