Skip to:
Content
Pages
Categories
Search
Top
Bottom

Setting BuddyPress pages to ‘noindex’ using Yoast SEO


  • notpoppy
    Participant

    @notpoppy

    I want to prevent pages generated by BuddyPress from appearing in search engines to avoid being penalised in rankings due to ‘index bloat’.

    I use Yoast SEO to control which parts of my site are and are not indexed. At present Yoast adds the following code to every page unless I set an option within the plugin not to do so:

    <meta name='robots' content='index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1' />

    However if I tell Yoast not to index a particular area of the site, such as the date-based archives, I can tell it to change that code to:

    <meta name='robots' content='noindex, follow' />

    I thought there might be a similar option to ‘noindex’ BuddyPress-generated pages. However after swapping emails with Yoast’s support team it turns out there isn’t because of the way BuddyPress is built:

    Unfortunately, it seems BuddyPress registers their group’s content type in a way that does not make it available to our plugin. We’re not sure exactly why this is, but it may be useful to check with their support team to see if they have a solution.

    As Yoast is such a popular plugin I thought others might have found a way to achieve this. I have found examples of code here for functions.pho which allows me to add ‘noindex’ to all BuddyPress-generated pages:

    function for_buddypress() {
        if ( is_buddyPress() ) {
            echo "<meta name=”robots” content=”noindex, nofollow>";
        } else {
        }
    }
    add_action( 'wp_head', 'for_buddypress' );

    But this appears in addition to the code added by Yoast, and it is obviously not a satisfactory to have both ‘index’ and ‘noindex’ on the same page.

    What I need is a way of telling the site ‘if this page has been generated by BuddyPress, do not add Yoast’s index code, add noindex code instead’. But my coding abilities aren’t up to this and I don’t even know where to start. Can anyone help please?

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

  • originalo
    Participant

    @originalo

    I am facing the same issue and highly appreciate any advise to solve the issue.
    Any idea???


    Sylvain L
    Participant

    @reventlov

    Hello,

    Thank you for your thread which helped me to find a solution.
    I was lokking to noindex profiles pages in buddypress.
    At least it works on my side. Hope that will help you guys.

    // Set a high priority to remove Yoast meta robots tags before they are added
    function remove_yoast_meta_robots() {
        if (function_exists('buddypress') && bp_is_user()) {
            // Remove Yoast's meta robots tag
            add_filter('wpseo_robots', function($robots) {
                return 'noindex, follow';
            });
        }
    }
    add_action('wp', 'remove_yoast_meta_robots', 1);
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar