title: Adobe CQ. Getting current page path
body: <p>I need to set current page path to <code>canocical</code> tag. Unfortunately I have some bugs here. On this code:</p>
  
  <pre><code>&lt;%
  ResourceResolver resolver = slingRequest.getResourceResolver();
  Externalizer externalizer = resolver.adaptTo(Externalizer.class);
  String canonUrl = externalizer.publishLink(resourceResolver, "http", currentPage.getPath());
  %&gt;
  &lt;link rel="canonical" href="${canonUrl}" /&gt;
  </code></pre>
  
  <p>I have this output:</p>
  
  <pre><code>&lt;link rel="canonical" href="" /&gt;
  </code></pre>
  
  <p>What is wrong. But if I setting <code>canonical</code> tag like this:</p>
  
  <pre><code>&lt;link rel="canonical" href="${currentPage.path}" /&gt;
  </code></pre>
  
  <p>I have this output:</p>
  
  <pre><code>&lt;link rel="canonical" href="/content/example/eu/germany/de_de/about.html" /&gt;
  </code></pre>
  
  <p>That's almost fine. And now, all I need it's just to add domain name(<em><a href="http://example.com/content/example/eu/germany/de_de/about.html" rel="nofollow">http://example.com/content/example/eu/germany/de_de/about.html</a></em>). But how I can do this without hardcoding? Approach should works fine also on localized pages.</p>