Get current page URL in Adobe CQ5 for Canonical Link

Is there a standard way in Adobe CQ5 to get the current page URL to create automatic canonical links in the JSP head?

Basically, we have a configuration dialog in which you can override the canonical link, but by default, if it's empty, I want to build the link based on the source URL for the current request.

The JSP for the header is used for all requests.

Many thanks

+4
source share
1 answer

${currentPage.path} , Externalizer, URL- (, , ) , , prod-server-123)

.

ResourceResolver resourceResolver = request.getResourceResolver();
Externalizer externalizer = resourceResolver.adaptTo(Externalizer.class);
String canonicalUrl = externalizer.publishLink(resourceResolver, "http", currentPage.getPath());

URL Felix osgi:Config node . Adobe.

( , CQ5.5 +)

+10

All Articles