Forums Forums Search & Filter Pro How to NoIndex Search result pages?

Tagged: 

Viewing 10 posts - 1 through 10 (of 14 total)
  • Anonymous
    #185597

    I want to stop pages that are generated by S+F from being indexed by search engines.

    I use the “As an archive” display method with a custom slug.

    Is this possible? If so, how exactly?

    Thanks!

    Anonymous
    #185612

    Would I need to:

    1.) Duplicate the template file I am using to display results from my theme.
    2.) Rename it to “custom-power-search.php” for example.
    3.) Add the code to the template so the “noindex” is enabled in this custom template.
    4.) Add that modified template to the child theme.
    5.) Set the “Custom template?” option in the plugin to yes and enter “custom-power-search.php”?

    Would that work?

    Thanks

    Trevor
    #185624

    That is one way to do it. Another is to simply install Yoast SEO:

    https://yoast.com/blocking-your-sites-search-results/

    Which is what I do on my personal sites.

    Anonymous
    #185649

    Hey Trevor.

    Thank you for your reply.

    I do have Yoast SEO installed and while it does block search results from the built in search in my theme, it is not blocking search results for the S+F results. I am seeing 230+ urls when I use the “site:”insert-doman-name” inurl:”insert-part-of-custom-slug-in-power-search-URLs”” operator searching on google.

    You can confirm that Yoast SEO does noindex S+F URLs when using the “As an archive” display method with a custom slug?

    Thanks!

    Trevor
    #185655

    I just checked, and it doesn’t. It will have to be the other route. This might be a good feature request, so I will raise it as well.

    Anonymous
    #185657

    Thanks Trevor.

    Do you know what code I would need to insert into the duplicated template file and where in the file exactly? For example where and what code would I add in the search.php or index.php file to have the noindex added to the search pages generated by S+F?

    Thanks!

    Trevor
    #185661

    It might be better to do this in the functions.php file of the child theme, maybe something like this:

    add_action('wp_head', 'noRobots');
    function noRobots() {
      if(strpos($_SERVER['REQUEST_URI'], '?_sf_s') !== false) {
        echo "\t<meta name='robots' content='noindex, nofollow' />\r\n";
      }
    }

    That might work better.

    Anonymous
    #185665

    Trevor, you are killing it man 🙂

    But why “?_sf_s”? I don’t see that in any of my URLs that are generated by S+F. Shouldn’t I insert “power-search-results” in the code instead? That is the custom slug I use for S+F.

    Thanks

    Trevor
    #185667

    Search and Filter passes the URL as a query string that always starts like that. It will only show in the URL bar if you make the search URL bookmarkable (one of the settings in the form), but it is there (hidden) if you do a search. That means your results page unfiltered is still indexed, but not when a search is done.

    Anonymous
    #185675

    Ah okay, so I should insert that code in the functions.php file of my active child theme and it should remove those result pages that are unfiltered? If yes, how can I test it to make sure it is setup and working properly?

    Thanks again!

Viewing 10 posts - 1 through 10 (of 14 total)