RE: Senna.js - disable adding of canonical url in Liferay DXP

Charlie Bird, modified 7 Years ago. New Member Post: 1 Join Date: 5/15/18 Recent Posts

We have a custom theme that sets and writes the <link rel="canonical" /> as we have quite complicated rules for this to help SEO.

I noticed that Senna.js writes its own version of the tag and we do not want to appear in the html head.

Is there any way of switching this specific behaviour off or will we have disable Senna.js completely?

 

Thanks

Ovidiu David Dan, modified 5 Years ago. New Member Posts: 15 Join Date: 1/23/17 Recent Posts
Have you found the way to disable adding of canonical url in Liferay DXP?
Thanks
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
Not sure which version you use, but we hooked top_head.jsp and replaced the canonical behavior of 7.0. You probably need to do something similar. But it could depend on the Liferay version.
Ovidiu David Dan, modified 5 Years ago. New Member Posts: 15 Join Date: 1/23/17 Recent Posts
Hello,I'm using Liferay 7.2.
I think I should overwrite top_head.jsp using custom jsp bag using Custom JSP Bags but according to the documentation override JSPs is a bad practice. With  Dynamic Includes or Portlet Filters    I would not be able to eliminate  <link data-senna-track="temporary" href="<%= HtmlUtil.escapeAttribute(canonicalURL) %>" rel="canonical" />
Do you think the only solution is Custom JSP Bags?
Thanks
thumbnail
Olaf Kock, modified 5 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts
Ovidiu David Dan:

I think I should overwrite top_head.jsp using custom jsp bag using Custom JSP Bags but according to the documentation override JSPs is a bad practice.
When changing a JSP, you'll always need to be aware of possible future changes to the underlying JSP as well. Prepare for 3-way-merges in case it does and you want to keep your installation current. That's why JSP manipulations are considered to be "brute force" and discouraged in general.
That being said, a single-line change in a JSP isn't that big of a hazard for future maintenance and is justifiable. The problem begins once you start bringing in conditionals and heaploads of functionality. In that case, you are better off with a single line change introducing a custom Dynamic Include, then implement that DI. Rather than adding a gazillion of lines to the JSP, that is.

As long as you make JSP changes your last-resort rather than your first choice change - there's an argument for them. Especially when you modify them with your future self (maintaining this patch) in mind. Do your future self a favor and make maintenance as easy as possible...
Ovidiu David Dan, modified 5 Years ago. New Member Posts: 15 Join Date: 1/23/17 Recent Posts
Thank you. Overwriting the jsp I've got to remove the canonical tag generated by default