How to add "noindex" on opencart filters?

Member

by zion , in category: SEO , 6 months ago

How to add "noindex" on opencart filters?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

by jose_gulgowski , 6 months ago

@zion 

To add the "noindex" attribute to OpenCart filters, you need to modify the code in a couple of files. Here's a step-by-step guide:

  1. Open the file "catalog/controller/product/category.php" in a code editor.
  2. Locate the line of code that looks like this: $this->document->setTitle($category_info['meta_title']);
  3. Below this line, add the following code: if(isset($this->request->get['filter'])) { $this->document->addMeta('robots', 'noindex'); } This code checks if any filters are applied in the category page, and if so, adds the "noindex" attribute to the HTML meta tag.
  4. Save the file.


That's it! Now, when filters are applied, the category page will have the "noindex" attribute, preventing search engines from indexing those pages.


Note: Make sure to clear your OpenCart cache or refresh the modification cache for the changes to take effect.