Expand my Community achievements bar.

SOLVED

Sitemap in AEM 6.5.13 not generating absolute URLs

Avatar

Level 2

Hi,

We are using the OOTB sitemap scheduler generation, and it's working as per the adobe tutorial, only problem is that our SEO team wants absolute URLs instead of the relative ones that we are getting:

https://mysite.net/content/mysite/mypage.sitemap.xml

<script/>
<url>
<loc>/content/mysite/mypage.html</loc>
</url>
</urlset>
what we want is:
<script/>
<url>
<loc>https://mysite.net/content/mysite/mypage.html</loc>
</url>
</urlset>
Also, is it possible to remove "/content" from the generation and just have the rewrite?
Any help would be appreciated!
Thanks
1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @SamFlyn

You would have to implement the shortening of URL to remove the /content from the sitemap generation. This can be handle by the following ways:-

1. Using sling mapping by setting node definition under /etc/map/https

2. Using sling resource resolver rules. Using the web console (for example, localhost:4502/system/console/configMgr) you can configure the Sling Resource Resolver:

Apache Sling Resource Resolver Factory
(org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl).

Here are the some links that you can follow to implement the shortening of URL in the sitemap.

https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/overview/seo-and-ur...

https://experienceleague.adobe.com/docs/experience-manager-learn/sites/seo/sitemaps.html?lang=en

https://blog.3sharecorp.com/shortening-urls-in-aem

Hope this helps.

View solution in original post

7 Replies

Avatar

Correct answer by
Community Advisor

Hi @SamFlyn

You would have to implement the shortening of URL to remove the /content from the sitemap generation. This can be handle by the following ways:-

1. Using sling mapping by setting node definition under /etc/map/https

2. Using sling resource resolver rules. Using the web console (for example, localhost:4502/system/console/configMgr) you can configure the Sling Resource Resolver:

Apache Sling Resource Resolver Factory
(org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl).

Here are the some links that you can follow to implement the shortening of URL in the sitemap.

https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/overview/seo-and-ur...

https://experienceleague.adobe.com/docs/experience-manager-learn/sites/seo/sitemaps.html?lang=en

https://blog.3sharecorp.com/shortening-urls-in-aem

Hope this helps.

Avatar

Community Advisor

you can add the domains in the Link externalizer(https://experienceleague.adobe.com/docs/experience-manager-64/developing/platform/externalizer.html?...) and useApache Sling Resource Resolver Factory to remove /content part 

or you have to extend the implementation like

https://github.com/arunpatidar02/aemaacs-aemlab/blob/master/core/src/main/java/com/community/aemlab/... 



Arun Patidar

Avatar

Level 2

@arunpatidar  Our situation is similar in that we don't have the /etc/mapping file and instead rely on the org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl to control everything. However, like you, we are still getting relative URLs instead of absolute ones. I came across your code and noticed that we have a similar custom code, but I'm not sure how it will assist us in rendering the URLs with the appropriate domain. I'm hesitant to resort to writing messy code that involves retrieving the domain and appending it to the URL. Do we the proper way to fix this with New Sling Sitemap Generator ?

Avatar

Community Advisor

Can you check wknd code? There it has absolute urls.

https://wknd.site/us/en.sitemap.xml 

 

I believe you can write a logic here if Link externalizer andJcrResourceResolverFactoryImpl config do not solve the issue

https://github.com/arunpatidar02/aemaacs-aemlab/blob/f96ce5316dfa4798c72d2e87d3a0b41fc49791a4/core/s... 

 

 



Arun Patidar

Avatar

Level 2

Thank you for your response @arunpatidar .

Do you have the latest repo URL for wknd? The following ones don't seem to be inlined with the cloud https://github.com/adobe/aem-guides-wknd

And yes I am manipulating the code as you mentioned but that again is a dirty way I feel.

Avatar

Community Advisor

The osgi configs are at https://github.com/adobe/aem-guides-wknd/blob/main/ui.config/src/main/content/jcr_root/apps/wknd/osg... 

 

I don't think so https://wknd.site/us/en.sitemap.xml is generated by OOTB sitemap generator.

 

You can continue to write custom logic to append domain



Arun Patidar

Avatar

Level 2

@arunpatidar Upon noticing the logs I see that the

SitemapGeneratorImpl extends ResourceTreeSitemapGenerator

 is never hitting which is why custom logic is also failing. When I track the requests the sitemap is only calling 

org.apache.sling.sitemap.impl.SitemapServlet

and the sitemap is getting generated. I have tried changing the ranking of that Impl but I don't think it will ever it that.