Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Should I use relative URLs in AEM?

Avatar

Level 2

We are globalizing our site and sharing content with regional partners. Sometimes we are forced to send a page with broken links, for example when the page has links to local-only or content they decided not to publish.

Increasingly we are using relative URLs within our links, like "/support/consumer/benefits.html" instead of using AEM's built-in page picker. Do we lose anything if we use relative URLs? And are there any better strategies for sharing mixed content like this? TiA

1 Accepted Solution

Avatar

Correct answer by
Level 2

The downside is that you can never really know if the content that is behind your link is actually available. Maybe vanity URL's can check it for you, or you can use a Transformer ( Apache Sling :: Output Rewriting Pipelines (org.apache.sling.rewriter​ ) to transform your normal URL's from the page picker to the relative ones? This way you can check if there is a relative URL and replace the current URL from the page picker to the relative URL when your page gets rendered.

Please note that this can have some impact on your performance though.

View solution in original post

3 Replies

Avatar

Correct answer by
Level 2

The downside is that you can never really know if the content that is behind your link is actually available. Maybe vanity URL's can check it for you, or you can use a Transformer ( Apache Sling :: Output Rewriting Pipelines (org.apache.sling.rewriter​ ) to transform your normal URL's from the page picker to the relative ones? This way you can check if there is a relative URL and replace the current URL from the page picker to the relative URL when your page gets rendered.

Please note that this can have some impact on your performance though.

Avatar

Level 2

Thanks very much for your replies. I was concerned AEM might lose some sort of internal tracking if we used relative URLs. The issue of broken links is less important. Since the global regions have to pay for translation cost, they can opt out of some pages. That results in broken links anyway.