Canonical urls not found in page source

  • Posts: 290
  • Thank you received: 22
1 year 11 months ago #341525

-- HikaShop version -- : 4.5.1
-- Joomla version -- : 4.1.3
-- PHP version -- : 8.0

Hi, I'm trying hard to figure out why there are no canonical url's visible in the code of the page.
I can see them in the products but they don't show in the source of the page.

I have the Force canonical set on "Use canonical URL and generate if missing".

Also I don't see any related errors in the console when turning error reporting to max.
The one plugin that is still giving an error I tried switching this one off but no luck.

So I'm a bit out of inspiration on where to look next.
Maybe you can give me a hint on things to check?

Please Log in or Create an account to join the conversation.

  • Posts: 81509
  • Thank you received: 13064
  • MODERATOR
1 year 11 months ago #341527

Hi,

The system will automatically add the canonical URL tag to the product details page of the product as long as the canonical URL field o f the product is not empty, regardless of the "force canonical URLs on listing" setting or other settings.
This is done by the code:

if(!empty($this->canonical)) {
	$doc = JFactory::getDocument();
	$doc->addHeadLink(hikashop_cleanURL($this->canonical), 'canonical');
}
at the beginning of the file product / show that you can edit via the menu Display>Views.
So first, I would recommend to check if that code is there because you could have a view override on that view file without that code, and in that case, it wouldn't add the canonical tag to the page, no matter what you do.
If that code is there, I would add some var_dump calls to check that the variable $this->canonical is properly filled and that it goes in the if.
If that's all ok, then HikaShop is adding the canonical tag to the headers. So that means it's probably either the template or a system plugin removing it. So switching the template to the default one, turning off the system plugins one by one would be the next step to figure out where the problem comes from.

Please Log in or Create an account to join the conversation.

  • Posts: 290
  • Thank you received: 22
1 year 11 months ago #341548

Hi,

Just checked and the code to generate the canonical is present. No overrides for the view product/show.

So I create a new menu-item for 1 product directly and compared the output with that of a page that was presented via the current categorielisting menu item.
I noticed that the direct menu-item contained the canonical url like expected.
Both pages had the same template assigned.
The pages looked exactly the same apart from the canonical url in the code.

I also tried turning of all the non-core system plugins without any luck.

Will ask a coder to help with the var_dump test to see if that learns us anything new.

Thanks.

Please Log in or Create an account to join the conversation.

Time to create page: 0.056 seconds
Powered by Kunena Forum