Request : How to no-index specific parameters in E-Commerce ? |

#937019
  • Resolved Adil
    Rank Math pro

    We are using Rankmath but we cannot locate where to no-index below parameters for our E-Commerce. These are not in specific posts nor pages.
    We want to no-index them so they don’t appear in Google Search Console anymore in the indexed pages :
    Also, once we no-index them, should we remove them from Robots.txt so that Google can crawl them and consider them no-indexed, then again put them back in Robots.txt ? Because right now we disallowed them already in Robots.txt but still they appear as indexed pages… :

    /?product_brands=
    /?product-tags=
    /?filter_ml=
    /?new=
    /?top-seller=
    /?rating_filter=
    /?on_sale=
    /?top-seller=
    /?our-selection=
    /?=min_price=
    /?filter_labels=
    /?add-to-cart=

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for your query and we are so sorry about the trouble this must have caused.

    Those types of pages are dynamic ones so Rank Math can’t set the robots meta settings for them in the backend. However, we can do a workaround by applying a filter code. Please refer to the code below:

    add_filter('rank_math/frontend/robots', function ($robots) {
    	$excluded_params = [
    		'add_to_wishlist',
    		'add-to-cart',
    		'product_brands',
    		'product-tags',
    		'filter_ml',
    		'new',
    		'top-seller',
    		'rating_filter',
    		'on_sale',
    		'our-selection',
    		'min_price',
    		'filter_labels',
    	];
    
    	$url = home_url($_SERVER['REQUEST_URI']);
    	foreach ($excluded_params as $param) {
    		if (strpos($url, '?' . $param . '=') !== false || strpos($url, '&' . $param . '=') !== false) {
    			$robots['index'] = 'noindex';
    			$robots['follow'] = 'nofollow';
    			break;
    		}
    	}
    
    	return $robots;
    });

    You may refer to this guide on how to add filters to your website: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    As for your inquiry about the robots.txt, yes, you can remove the disallow rules for these parameters from robots.txt temporarily. This lets Google crawl the URLs and respect the noindex directive in the meta. Once de-indexed, you can block them again if desired.

    Hope that helps.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘Request : How to no-index specific parameters in E-Commerce ? |’ is closed to new replies.