How to noindex “add to cart” pages?

#993739
  • Resolved Alireza
    Rank Math free

    My google console says that it is indexing pages of the type “?add-to-cart=3463321110”. I already blocked them in my robots.txt file, but google says the best practice is to block them by noindex. Where in rank math can I mark them as noindex? Thank you!

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

    We apologize for the issue you’re facing with the indexing of your "add to cart" pages. To set these pages to noindex using Rank Math, you can follow these steps:

    1. Navigate to Rank Math SEO Settings: Go to your WordPress admin area and click on Rank Math SEO in the sidebar.
    2. Titles & Meta: Click on Titles & Meta.
    3. Product Pages: Look for the section related to Products or Product Archives.
    4. Noindex Option: In the settings for product pages, you should find an option to set the No Index tag. Enable this option to prevent Google from indexing those pages.

    Product category archives indexing

    1. Save Changes: Don’t forget to save your changes after making adjustments.

    By setting the noindex tag, you ensure that Google understands not to index these pages, which is indeed a best practice compared to just blocking them in the robots.txt file.

    If you have any further questions or need assistance with specific settings, feel free to reply to this ticket, and a human agent from our support team will assist you further. Thank you for raising this concern!

    Sources:
    How Rank Math Prevents Duplicate Content Issues in a WooCommerce Store » Rank Math

    I’m looking to noindex “?add-to-cart=” pages.

    What is a category archive page anyway? To be sure, I want my product category pages to be indexed!!

    Hello,

    Thank you for your patience.

    You can only set those URLs with add-to-cart parameter by using this filter on your site:

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

    Here’s a guide you can follow to apply that:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Also, you should not include a disallow rule in your robots.txt for those filter paths so Google can read the noindex meta tag.

    Looking forward to helping 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 3 replies - 1 through 3 (of 3 total)

The ticket ‘How to noindex “add to cart” pages?’ is closed to new replies.