Canonical urls not removing from website ( Concrete5.8.3.1)

Permalink 1 user found helpful
Hello Team,

We are developing a website in concrete5.8.3.1. We have un-checked option "canonical urls" from admin section but still canonical urls are displaying on webpages. I have cleared cache as well. Can you please let me know what can cause this issue ?

Thanks in advance
Akash Sharma

 
A3020 replied on at Permalink Reply
A3020
Are those URLs from Content blocks, or from other kind of blocks? If they are Content blocks, make sure the URLs have been created using the page selector. If they are 'hard coded' URLs, of course they don't change when a config setting changes.
akashsmartshore replied on at Permalink Reply
Hi,

Thanks for you reply.

No, canonical tag is generated from concrete header_required.php file.
When I turn off this option from concrete config even the also below is generated on all pages.
<link rel="canonical" href="">

The problem is we have a single page and the url of page looks like 'http://www.domain.com/news/1" and "1" is dynamic id of object. when we check page source of single page, canonical url looks like "<link rel="canonical" href="http://www.domain.com/news">, but it should also keep "1" . Is there any solution for this?. Otherwise we have to remove canonical tag from page or we have to override header_required.php.

Please update us ASAP and our client is not able share urls on Facebook and LinkedIn.

Thanks
A3020 replied on at Permalink Reply
A3020
Why don't you hook into the 'on_header_required_ready' to alter the 'linkTags' property?
akashsmartshore replied on at Permalink Reply
Hi,

Thanks for your reply.

I have done some research and I am able to find how to use "on_header_required_ready" event. I have below questions before implementation:

1) We want to change canonical url of single page only which is inside a package. Do we need to call "on_header_required_ready" in package on_start ?.

2) Inside event "on_header_required_ready", we need to add check if pageId is equal to our single then then only we will override canonical url ?

Thank you very much!
A3020 replied on at Permalink Reply
A3020
You shouldn't 'fire' the event in the pkg on_start, you should 'hook into' / 'listen' to it. See https://github.com/concrete5/concrete5/issues/4310#issuecomment-2441... for an example.
akashsmartshore replied on at Permalink Reply
Hi,

Thank you very much for the solution. We are able to use event mentioned by you.

One general question, If we want to override meta for a particular page, do we need to add check of pageId ? so that if current page id is equal to our page then code should execute, or is there any other good way because pageId can different for development and live environments.

Thanks
A3020 replied on at Permalink Reply
A3020
Yes, you'd need a condition in the even listener that either keeps the linkTags intact, or not. I don't know enough about the system you're building to answer that question. But the condition of course can be based on the page type, page template, page id, page path, a page attribute, etc...
akashsmartshore replied on at Permalink Reply
Thank you very much. We have resolved this issue.

Thanks