Canonicalization tag issue with ?add-to-wishlist parameter url

#575874
  • Resolved Anonymous
    Rank Math free

    Hi, I need help with a problem with the ?add-to-wishlist parameter url, I checked your knowledge base, but there is no help for this.

    Problem description: I found some errors in Google Search Consle, such as https://mydomain.com/product/example-prodcut/?add-to-wishlist=14438, the reason for the error is: Alternate page with proper canonical tag. Google crawls thousands of these urls, causing my correct product content to be seen as duplicate content and not indexed. This is true for hundreds of my products, and I’ve read that RankMath will automatically set the correct normalization tags, but apparently it doesn’t work, and Google reports that the problem persists. Since https://mydomain.com/product/example-prodcut/?add-to-wishlist=14438 is not an actual url, I can’t set its normalized url either.

    I need help telling me how to solve this problem, it’s been bugging me for ages and I don’t know if RankMath can handle it.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    Could you please share some sample affected product URLs so we can verify them as well? The canonical URL of those should be pointed to the actual product URL to avoid duplicate content issues.

    Please also note that the “Alternate page with proper canonical tag” is not an error. Google will simply exclude the duplicate versions (URLs with wishlist) and index the main version of the page/product.

    Meanwhile, you can add the following rules to your robots.txt file in WordPress Dashboard > Rank Math > General Settings > Edit Robots.txt to prevent Google from crawling such URLs:

    Disallow: *?add_to_wishlist=*
    

    Hope that helps.

    Thank you.

    Anonymous
    Rank Math free

    I tried disallowing crawlers to crawl rules with this parameter in the Robots.txt file, as you said: Disallow: *?add_to_wishlist=*, but it didn’t solve the problem. Because Google can’t crawl these pages, I have made an error in Google Search Console, and there is an error in submitting Google for review (because Google says it can’t crawl), so my problem has not been resolved for a long time. Does RankMath have any way to handle URLs with parameters?

    The problem here is that Google thinks that my actual product page and the url with the add-to-wishlist parameter are duplicate content, so many of my products cannot actually be included. Google does not know which is the correct canonical tag. Does RankMath have some Can a function handle this?

    I checked the https://mydomain.com/product/example-prodcut/?add-to-wishlist=14438 and, https://mydomain.com/product/example-prodcut/ pages by looking at the source, https ://mydomain.com/product/example-prodcut/ has an explicit canonical tag in the html code section. But https://mydomain.com/product/example-prodcut/?add-to-wishlist=14438 doesn’t have this tag in the code. And since https://mydomain.com/product/example-prodcut/?add-to-wishlist=14438 is not a page that actually exists, I cannot edit it and set normalization tags. I can only make edits to the product https://mydomain.com/product/example-prodcut/ which actually exists.

    Nigel
    Rank Math business

    Hello,

    Thank you for your patience as we look into your canonical tag issue.

    You can add the following filter to your website to set the canonical to the URL version without query parameters on product pages:

    
    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
        if (function_exists('is_product') && is_product() && !empty($_GET)) {
            $canonical = strtok($canonical, '?');
        }
        return $canonical;
    });
    

    You can follow this guide for how to add filters to your website: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps. Please let us know if you have questions.

    Anonymous
    Rank Math free

    Ok, thank you very much for your assistance, in fact, I have used this method before, I used the Code Snippets plug-in, installed a piece of code, the code is as follows:

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
    $url = home_url( $_SERVER['REQUEST_URI'] );
    if ( strpos( $url, '?add-to-wishlist' ) !== false ) {
    $robots["index"] = 'noindex';
    $robots["follow"] = 'nofollow';
    }
    return $robots;
    });

    And I set this code to run on the whole website, but it still didn’t improve the situation, I’m not sure if your code is similar to mine.

    Hello,

    If you’re using that filter, then they should be set to noindex, and the canonical will not be added.

    You can share the affected URLs with /?add-to-wishlist in the sensitive data section, so we can check them further.

    Sensitive Data Section

    It is completely secure, and only our support staff has access to that section.

    Looking forward to helping you.

    Thank you.

    Anonymous
    Rank Math free

    Can I use this script code:

    add_filter( ‘rank_math/frontend/canonical’, function( $canonical ) {
    if (function_exists(‘is_product’) && is_product() && !empty($_GET)) {
    $canonical = strtok($canonical, ‘?’);
    }
    return $canonical;
    });

    and run it to all pages of the site, will this solve the problem?

    Hello,

    If you have applied the previous filter you mentioned here, then you won’t need that filter as the canonical will not be added if those URLs are set to noindex.

    However, this filter will set the canonical URL to be self-referencing. If they have self-referencing canonical URLs, they are prone to duplicate content issues.

    If those URLs with /?add-to-wishlist have canonical URLs pointing to the product itself (https://mydomain.com/product/example-prodcut/), then Google will determine which version should be indexed as mentioned in our guide here:
    https://rankmath.com/kb/alternate-page-with-proper-canonical-tag/#num-1-what-does-alternate-page-with-proper-canonical-tag-mean

    Looking forward to helping you.

    Thank you.

    Anonymous
    Rank Math free

    I used that noindex filter, but that doesn’t seem to work for google, the already existing error pages persist. Can’t get rid of it, it seems that using other SEO plugins doesn’t have this problem. I am now using the normalized script code provided by you. I can now see that the url with parameters has also added a normalized tag to point to the correct url by looking at the source code. I will observe and see if I can fix the error.

    Hello,

    As the correct canonical URL is being added to the /?add-to-wishlist URL, so it’s just a matter of time when Googlebot re-crawls the website and fix the issue in GSC itself.

    Do let us know if the issue isn’t resolved after few days, do share few URLs with us o we can check them further.

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

    Thank you

    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 9 replies - 1 through 9 (of 9 total)

The ticket ‘Canonicalization tag issue with ?add-to-wishlist parameter url’ is closed to new replies.