Canonical Tags | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

arunpatidar
Community Advisor
Community Advisor
June 19, 2018

Yes, you can do it by using Java/JS/HTL

In head, you can do something like below:

Head.js

use(function () {

    return {

        canonical:"https://aem63app.com"+currentPage.getPath()+".html"

    };

});

head.html

<sly data-sly-use.head="head.js">

<link rel="canonical" href="${head.canonical}"/>

<!--/* Include Context Hub */-->

Or you can use java and apply your business logic and return href value.

Thanks

Arun

Arun Patidar
exzyte
exzyteAuthor
Level 2
June 19, 2018

Hi Sir,

I don't have access to update/edit AEM templates.

I have tried adding canonical tag <link rel="canonical" href="https://www.samplelink.com/en/contactus.html" /> thru Adobe DTM but it is not reflecting on "view page source" and also on elements tab of Devtools.

regards

arunpatidar
Community Advisor
Community Advisor
June 19, 2018

Hi,

I have no idea about DTM but other people in forum can help. but how did you injected canonical tag in the page? If you are injecting canonical tag on runtime using javascript, then It won't be appears in page source but it will be added in page and you can check using inspect element in browser.

Are you able to put javascript logger , e.g. console.log("Canonical Added" ) something like that, so that you can be sure code is executing or not.

Thanks

Arun

Arun Patidar