Expand my Community achievements bar.

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

Url shortening when using handlebar in AEM

Avatar

Level 4

We are using handlebar in AEM. We are passing the AEM authored data as a context to the handlebar template. It works fine. In the AEM component dialog, we have a link field that has a path starting with /content/<appname>

.When I render this component with handlebar.hbs file, the link is not getting shortened, but when we put this component on the HTML page, Apache resource resolver configuration comes into the picture, and shortens the URL as per the URL mapping defined. I know we can use the resource resolver .map()  function map the shorten the URL in the data but I would like to know if there any other way we can fix to shortened the URLs while using the handlebar? 

2 Replies

Avatar

Level 4

Hi @karanmahi ,

 

It is advisable to use config  Apache sling resource resolve factory for field resource.resolver.mapping only for publish instance to test it like a live environment.

 

Thus, if you have this configuration in the Author or common config folder, move it to config. publish folder and link should start working on Author as it is.

 

Screenshot 2021-02-08 at 12.53.42 PM.png

 

I am sure, you do have also all the standard mappings/rules on dispatcher like to map a hostname to AEM sites, etc.

Avatar

Level 4
This is not what i asked in my question. My question is about how to shorten the url in handlebar .hbs file