Index the archive page, but noindex the posts

#810920
  • Resolved Cosmin Ioan
    Rank Math free

    Hi, I run a directory type website, and the listings are not for too long available, so I need to block the indexing.

    On rankmath settings, I can set noindex, but it automatically sets the /archivepage/ as no index aswell.

    Is there an option to:

    index doamin.com/archivepage
    noindex domain.com/archivepage/listing1 , /listing2 etc? Literally to noindex everything that’s after archivepage/

    Thank you!

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

    I understand your concern about wanting to index the archive page while setting the individual listings under that archive page to noindex. To achieve this with Rank Math, you can follow these steps:

    1. Go to your WordPress Dashboard.
    2. Navigate to Rank Math SEO > Titles & Meta > Misc. Pages.
    3. Enable the option for Noindex Paginated Single Pages as shown in the screenshot below:

    NoIndex Paginated Single Pages

    By enabling this option, you will set noindex on paginated pages, including individual listings like /listing1, /listing2, etc., while keeping the archive page indexed.

    If you need further assistance or have any more questions, feel free to reach out to our support team here.

    Thank you for reaching out with your query!

    Sources:
    Rank Math ‘Titles and Meta’ Options and Settings
    How to NoIndex Paginated Pages Ā» Rank Math
    How to Noindex URLs With Rank Math Ā» Rank Math
    Using Rank Math’s ‘Quick Actions’ Admin Menu Item

    Hello,

    Thank you for contacting us and bringing your concern to our attention.

    You can use the following filter on your website and see if that works for you:

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
        $url = home_url( $_SERVER['REQUEST_URI'] );
    
        // Index the archive page
        if ( $url === home_url( '/archivepage' ) ) {
            $robots["index"] = 'index';
            $robots["follow"] = 'follow';
        }
    
        // Noindex specific archive listings
        elseif ( strpos( $url, '/archivepage/listing' ) !== false ) {
            $robots["index"] = 'noindex';
            $robots["follow"] = 'nofollow';
        }
    
        return $robots;
    });
    

    Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Let us know how it goes. Looking forward to helping you.

    Thank you.

    Hi,

    Thank you for getting back to me. This is not really working.

    The archive page is called “rooms”. Could you think of a code to index domain.com/rooms, but no index everyhint that will be under “rooms” e.g domain.com/rooms/”123″

    Thank you for your time!

    Hello,

    In this case, please try this filter code instead:

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
    	$url = home_url( $_SERVER['REQUEST_URI'] );
    	$pattern = "/room\/\d+/";
    
    	if (preg_match($pattern, $url)) {
    		$robots["index"] = 'noindex';
    		$robots["follow"] = 'nofollow';
    	}
    
    	return $robots;
    });

    Let us know if that would work.

    Looking forward to helping you.

    Amazing! This one is working! Thank you very much for your support!

    Hello,

    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.

Viewing 6 replies - 1 through 6 (of 6 total)

The ticket ‘Index the archive page, but noindex the posts’ is closed to new replies.