How to set rel=”nofollow” for WooCommerce filter links with query parameters?

#1031560
  • Resolved Laptoria
    Rank Math pro
    Content AI Starter

    Hi Rank Math Support,

    I’m having an issue with Googlebot crawling and indexing thousands of filtered URLs on my WooCommerce shop. Here’s an example from my logs:

    66.249.66.199 - - [16/May/2025:09:12:37 +0200] "GET /shop/?highlight_filter=featured&filter_arbeitsspeicher=24-gb,64gb&filter_prozessor=intel-core-i3-6100t,..." ...

    I understand that Rank Math can set noindex for URLs with specific query parameters (like highlight_filter, filter_arbeitsspeicher, etc.), but I also want to make sure that all filter links (that generate such URLs) have the rel=”nofollow” attribute, so that Googlebot does not follow them at all.

    Is it possible to automatically add rel=”nofollow” to these filter links using Rank Math, or do I need to handle this separately (for example, via custom code or another plugin)?
    If there is a way to do this via Rank Math, could you please provide a step-by-step guide?

    Thank you in advance!

Viewing 1 replies (of 1 total)
  • Hello,

    We apologize for the issue you are facing with Googlebot crawling and indexing filtered URLs on your WooCommerce shop. Thank you for raising this concern.

    To automatically add the rel="nofollow" attribute to filter links generated by WooCommerce, you can use Rank Math’s settings. However, please note that Rank Math does not have a built-in feature specifically for adding rel="nofollow" to query parameter links directly. Instead, you can manage this through the following steps:

    Step-by-Step Guide to Add Nofollow to Filter Links:

    1. Navigate to Rank Math Settings:

      • Go to your WordPress dashboard.
      • Click on Rank Math in the left sidebar.
      • Select General Settings.
    2. Enable Nofollow External Links:

      • In the General Settings, look for the Links tab.
      • Enable the Nofollow External Links option. This will apply the nofollow attribute to all external links by default.

      Enable Nofollow External Links

    3. Add Specific Domains to Nofollow:

      • If you want to add specific domains or URLs to be nofollowed, you can use the Nofollow Domains option under the same Links settings. Enter the domains that you want to apply the nofollow attribute to, one per line.

      Adding domains under Nofollow Domains

    4. Custom Code (if necessary):

      • If you need more granular control over specific query parameters or WooCommerce filter links, you may need to implement custom code in your theme’s functions.php file or use a custom plugin. This would involve hooking into WooCommerce’s output and adding the rel="nofollow" attribute to those specific links.

    Example of Custom Code:

    Here’s a simple example of how you might add rel="nofollow" to specific links:

    add_filter('woocommerce_loop_add_to_cart_link', 'add_nofollow_to_filter_links', 10, 2);
    function add_nofollow_to_filter_links($link, $product) {
        if (strpos($link, 'highlight_filter') !== false || strpos($link, 'filter_arbeitsspeicher') !== false) {
            $link = str_replace('href=', 'rel="nofollow" href=', $link);
        }
        return $link;
    }

    This code checks if the link contains specific query parameters and adds the rel="nofollow" attribute accordingly.

    Conclusion:

    While Rank Math provides some options for managing nofollow attributes, for specific query parameters like those in WooCommerce filter links, you may need to implement custom code for complete control. If you have further questions or need assistance with the custom code, please reply to this ticket, and a human agent from our support team will assist you further.

    Thank you for your understanding, and we hope this helps resolve your issue!

    Sources:
    How to Nofollow Specific External Links in WordPress With Rank Math SEO » Rank Math

    This is an automated reply from Rank Math Support Bot. If you need further assistance, please reply to this topic and a human support agent will reply to you shortly.

    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 ‘How to set rel=”nofollow” for WooCommerce filter links with query parameters?’ is closed to new replies.