AEM 6.5: HTL @ extension = 'html' doesn't work for external links | Community
Skip to main content
nikunjj81682294
Level 2
September 18, 2019
Solved

AEM 6.5: HTL @ extension = 'html' doesn't work for external links

  • September 18, 2019
  • 4 replies
  • 7892 views

${ link @ extension = 'html' } if link is https://www.google.com/resources then the output is https://www.google.com/resources.html. This is not the expected behavior according to the documentation. Any help is appreciated. Thanks, Nikunj Jariwala

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by user05162

If you want to remove the extension, you can use something like below:

${'https://www.google.com/resources' @  extension}

4 replies

Adobe Employee
September 18, 2019

As per my understanding and the sly documentation at [1], @1917396 will add the extension to the path. So, this is working as expected.

URL manipulation

Adds the html extension to a path.

<a href="${item.path @ extension = 'html'}">${item.name}</a>

Adds the html extension and a selector to a path.

<a href="${item.path @ extension = 'html', selectors='products'}">${item.name}</a>

I tried the following on my side:

  ${'https://www.google.com/resources' @  extension='html'}

The output is below:

Screen Shot 2019-09-17 at 8.52.23 PM.png

[1] HTL Block Statements

nikunjj81682294
Level 2
September 18, 2019

https://docs.adobe.com/content/help/en/experience-manager-htl/using/htl/block-statements.html#sly-element The documentation on this page says "The @1917396 works in all scenarios in AEM 6.3, before you could have a result like www.adobe.com.html and also checks whether to add or not add the extension." The use case is that we dont want to add html to external links. Is that something which cannot be solved using @ extension?

user05162Adobe EmployeeAccepted solution
Adobe Employee
September 18, 2019

If you want to remove the extension, you can use something like below:

${'https://www.google.com/resources' @  extension}

Adobe Employee
September 18, 2019

I do not think that HTL has such functionality to distinguish internal/external links. You will need to write something custom to handle case a use case. Take a look at this [1] to help you in creating this customization.

[1] https://wcm.io/handler/link/usage.html