Rendering a link that might be internal or external | Community
Skip to main content
New Participant
December 11, 2017
Solved

Rendering a link that might be internal or external

  • December 11, 2017
  • 5 replies
  • 5583 views

I'd like to allow authors to specify the href of a link by either using the pathbrowser to browse to a path on the site like /content/site/path/to/page, or pasting in an external URL, like http://www.example.com. In the first case, I would want to append .html; in the second, I wouldn't. This seems like a reasonably common scenario, so I was thinking there might be some OOTB support, either in Java APIs, or Sightly/dialog functionality. I haven't found anything yet - is there anything? Or ACS Commons? (I'm using AEM 6.1 and Touch UI)

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 iainc65537558

Looks like this has been raised as a bug [SLING-7548] HTL url manipulation for external link without extension - ASF JIRA

5 replies

iainc65537558Accepted solution
New Participant
March 21, 2018
New Participant
March 20, 2018

I am having the same issues here - entry pages seem to work fine, but anything deeper gets the .html added to the URL.

<a href="${ '/content/myproject/en' @ extension='html'}">Internal Link</a>   Adds the .html extension [correct]

<a href="${ 'https://www.adobe.com' @ extension='html'}">External Link</a> Does not add the .html extension [correct]

<a href="${ 'https://www.adobe.com/uk' @ extension='html'}">Deeper External Link</a> Adds the .html extension [not right]

This does seem like a bug - unless we are doing it wrong.  In which case is there a better way to output a link correctly that could be either external or internal?

New Participant
December 11, 2017

I just ran a few more tests, and looks like this is functionality that updated in 6.3. 6.1 and 6.2 append .html to everything, 6.3 distinguishes between internal and external links.

New Participant
December 11, 2017

Have you tried that against v6.1? My test was showing the latter example DID add .html to the external URL.

edubey
New Participant
December 11, 2017

You can use @ extension attribute in sightly

Example:

Will add .html to the internal page url

<a href="${ '/content/project/en' @ extension='html'}">Internal Link </a>

Will not add .html to the external domain url

<a  href="${ 'http://www.adobe.com' @ extension='html'}">External Link </a>