Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @alexliii,

    Thank you so much for getting in touch.

    You should let Rank Math generate the self-referencing Canonical URL for all the products to avoid duplication issues.

    In the previous support thread, you have noindexed the filter URL so Google will no longer report such an error.

    You can go ahead and replace the code with this modified one:
    add_filter('rank_math/frontend/robots', function ($robots) { $url = home_url($_SERVER['REQUEST_URI']); if ((strpos($url, "?filter_color=") !== false) || (strpos($url, "?attribute_pa_") !== false)) { $robots["index"] = 'noindex'; $robots["follow"] = 'nofollow'; } return $robots; });
    Hope that helps.

    Thread Starter alexliii

    (@alexliii)

    Great thanks for reply.

    Please allow me verify with you again.

    By following Google policy at https://support.google.com/merchants/answer/7052112?hl=en

    Usually, we need set attributes like Color, Size, Material for most of product, and for some products, we even need set Capacity (Value, like 40 Liters)

    So, for most variable products, there will be variations at frontend like this screenshot:

    https://prnt.sc/HAj-rHfLukA9

    I just suppose that is the reason why there is report of Alternate page with proper canonical tag on Google Search console, like this one:

    https://mysite.com/shop/school-bag/16-inch-waterproof-clean-color-kawaii-school-backpack-bag-for-girl/?attribute_pa_color=white&attribute_pa_size=16-inch&attribute_pa_capacity=20-liters&wmc-currency=USD

    Two questions:

    1# So, do you mean Rankmath always automatically generate Canonical URLs for all products?

    2# Will the your last code snippets solve or avoid Alternate page with proper canonical tag on Google Search console? include Color, size, material, capacity?

    Thanks in advance.

    • This reply was modified 8 months ago by alexliii.
    • This reply was modified 8 months ago by alexliii.
    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @alexliii,

    1. Rank Math adds the canonical tag to all the indexable URLs. However, the variations and attribute filters have the canonical set as the URL of the main page to avoid duplicate content issue.
    2. The filter will set the attribute variations to noindex. Since they will be set to noindex, the canonical tag will be removed and you will no longer get the canonical issue in your GSC account.

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Does Rankmath set Canonical URLs by default?’ is closed to new replies.