Hello there.
I have a situation that I don’t know how to solve:
in GSC, I have this: “Alternate Page with Proper Canonical Tag” for many urls of the type /?add_to_wishlist=78301&_wpnonce=7f4061d921
I use “YITH WooCommerce Wishlist” for the wishlist, the module is compatible (recommended by the theme).
For cache I use “WP Super Cache”. Here I put “wishlist” to “Rejected URL Strings” and “yith_woocompare_list” to Rejected Cookie.
Also, the “wishlist” page has No Index, Schema: Off
How can I fix this please?
Thank you.
Hello,
Thank you for your query and we are so sorry about the trouble this must have caused.
It looks like most of these pages are only attributes and filters being applied on the page. These are applied whenever a user interacts on one of your pages and the filter or attribute is written on the URL to help your website remember which option the user has selected.
Most of these can be safely ignored since they are being directed to your pages. The only time this would be an issue is if one of your posts/pages has this error and is redirecting to a completely different post.
The “Alternate Page with Proper Canonical Tag” status message in Google Search Console means that there are two versions of a page on your website having the same canonical URL. Google will simply exclude the duplicate version and index the main version of the page.
This ideally means Google recognizes these canonicalized URLs correctly, and there is nothing you need to do on your part.
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Hello and thanks for the answer.
I know what this means, but I wanted to know how I could get rid of them, even if they can be ignored.
Would it be a correct solution, without changing anything negative, to add text to the robot file?
Disallow: /?add_to_wishlist=*
Hello,
The URLs with add to wishlist you have shared are set to index.
If you have chosen to block them using your robots.txt as you have shared, they will end up in a Blocked by robots.txt
error:
https://rankmath.com/kb/fix-submitted-url-blocked-by-robots-txt-error/
However, since those URLs are unique to each user like add-to-cart, my-account, etc., then they should be set to noindex.
Here’s a filter you can use to modify them in bulk:
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;
});
You can add the filter to your theme’s functions.php file or you can follow any of the methods mentioned in the guide below to add this filter to your website:
https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope that helps.
Thank you.
Hi.
This seems to be the good solution.
Thank you very much.
Hello again,
We are glad to hear that this issue has been resolved. Thank you for letting us know. This ticket will be closed now, but you can always open a new one if you have any other questions or concerns. We are here to help you with anything related to Rank Math.
We appreciate your patience and cooperation throughout this process.
Thank you for choosing Rank Math.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.