Some product listing pages have robots noindex in alternate urls

  • Posts: 68
  • Thank you received: 10
  • Hikashop Essential
2 years 5 months ago #342534

-- HikaShop version -- : 4.4.3
-- Joomla version -- : 3.10.9
-- PHP version -- : 7.4.9

Dear Hika team,

I have a problem with some of my product listing pages. These pages can not be indexed by Google because they have meta noindex in the alternate urls and I don't how how to get rid of it.

Members of the Dutch Joomla forum have also looked into the backend, but they can't find what it is either.

I have already created another menu item for the "Universeel" category with a different alias, but noindex still remains in the page source.

The strange thing is that it is placed in some pages and not in others (see att).

Can you please tell me how I can remove noindex from those pages?
Thanks in advance!

Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 5 months ago #342535

Hi,

In the file components/com_hikashop/views/product/view.html.php you have this code:

if ($this->params->get('robots')) {
				$doc->setMetadata('robots', $this->params->get('robots'));
			}
which is actually now this code in more recent versions of HikaShop:
			$robots = $this->params->get('robots');
			if (!$robots) {
				$jconfig = JFactory::getConfig();
				$robots = $jconfig->get('robots', '');
			}
			if($robots) {
				$doc->setMetadata('robots', $robots);
			}
That's the code which adds the tobots tag on the products listing if it finds it set in the menu item settings.

So basically:
- either you configured your menu item's robots setting wrongly
- or that meta tag isn't added by HikaShop.
A simple way to check is to remove that code from that file, clear your browser and website caches and if you still see the robots tag, then it doesn't come from HikaShop but something else.
And if it removes the tag from the headers of the page, then it means that you need to check the robots setting of your menu item.

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

  • Posts: 68
  • Thank you received: 10
  • Hikashop Essential
2 years 5 months ago #342551

Hi Nicolas,

Thank you for your reply.
I did what you said. Unfortunately the tag was not removed, but the one from the header was.
I had deliberately set this menu item to index, follow to see if Google could index it. The rest of my menu items are on Use Global which I also have on index, follow.

So it looks like this tag doesn't come from Hikashop, does it?

By the way, can I now omit that piece of code from view.html.php or better put it back?

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 5 months ago #342553

Hi,

Then it indeed means tha this robots tag with the noindex doesn't come from HikaShop.
It's probably coming from a plugin of the group "system", or the template.

You can keep the code in view.html.php. When you update HikaShop in the future, the code will be added back automatically anyways.

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

  • Posts: 68
  • Thank you received: 10
  • Hikashop Essential
2 years 5 months ago #342557

Hi Nicolas,
I had just finished typing this message when I received your reply via email, but I just found out what it is.
After hours of searching and enabling and disabling possibly relevant plugins and components, it was finally a problem in Hikashop -which I had done myself by the way-.

I found out when I tried another template and the noindex tag was gone in the source code.
So I downloaded the template I use to my desktop and searched it with Notepad++.
It turned out that it was in a code I put in listing_img_title.

<?php
if($this->row->meta_noindex == 'true'){
  	$doc = JFactory::getDocument();
	$doc->addCustomTag( '<meta name="robots" content="noindex" />' );
}
?>

I have created a custom product field with meta_noindex and default value "false".
The reason I did dis is that every month I have special offers with characteristics that I place in option products;
This message contains confidential information


In those option products I set the custom meta_noindex field to “true” because these products are removed after a month so I don't want them indexed by Google to prevent 404 errors.
And all categories/product listing pages that contain such a product offer are marked in the source code as noindex. That also explains why one product page has it and the other does not.

Once I removed the code from listing_img_title the noindex tag was also gone from the source code.
So I'm really glad the issue has been resolved, but I'd still like those option products not to be indexed by Google because they're only valid for one month and then I'll remove them again.

Is there another way to prevent these options products from being indexed by Google?

Last edit: 2 years 5 months ago by HSD. Reason: Edit to add translated link and typo

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 5 months ago #342558

Hi,

The thing is that product / listing_img_title if for the listings, so you custom code would deindex the whole listing as long as one product would have that flag activated.
Instead, you should add your code in product / show (and change $this->row by $this->element ). That way, it would add the meta tag on the product details page, not on the listing.

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

  • Posts: 68
  • Thank you received: 10
  • Hikashop Essential
2 years 5 months ago #342628

That way, it would add the meta tag on the product details page, not on the listing.


Thank you Nicolas.
But won't the problem be moved to the product instead of the product page?
I mean: that Google considers that product details page as noindex?

Last edit: 2 years 5 months ago by HSD.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 5 months ago #342629

Hi,

Isn't that your goal to deindex some product details pages from Google with that custom code ?
If you don't want any products to be deindexed from Google, then you shouldn't use that custom code at all.

The problem you had with that custom code was that it was deindexing the whole listing instead of a specific product page when you were activating the custom field in the product.
With what I propose, it will only add the noindex tag to the product details page of the products where you activated custom field (which is what you want I believe).

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

  • Posts: 68
  • Thank you received: 10
  • Hikashop Essential
2 years 5 months ago #342646

Hi Nicolas

Maybe I didn't make myself clear.
I DO want the main product to be indexed by Google but not the Option products since these are only valid for 1 month and then they will be deleted again. And every month there are other Main products that have Option products (with different offers).

I try to explain in attachments.

Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 5 months ago #342652

Hi,

The code you want to use will add the meta tag to the product details page of the option product, not to the product details page of the main product.
So I still believe it will do what you want if you add it to product / show. But if you don't believe me, just try and you'll see.


Maybe I'm myself not clear in my previous messages so here it is in short:
Add

<?php
if($this->element->meta_noindex == 'true'){
  	$doc = JFactory::getDocument();
	$doc->addCustomTag( '<meta name="robots" content="noindex" />' );
}
?>
to product / show and it will work like you want.

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

  • Posts: 68
  • Thank you received: 10
  • Hikashop Essential
2 years 5 months ago #342684

Hi Nicolas,

It's not that I didn't believe you but I thought you didn't understand my explanation.
But I tried it in product/show and tested the main product with the option product in Search Console and again you are my life saver because the page could be indexed. :lol:

Thank you very much!

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

Time to create page: 0.065 seconds
Powered by Kunena Forum