WordPress.org

Forums

All in One SEO Pack
[resolved] Remove Canonical tag when noindex selected (7 posts)

  1. solosails
    Member
    Posted 11 months ago #

    Hi,

    Is there a way to get AIOSEOP to remove the canonical meta if noindex meta is selected?

    I have read in a few places that this shouldn't be done, either one or the other, however, in AIOSEOP, you can have both selected at the same time.

    Is there a way for now that one could write a conditional that removes the canonical tag if the noindex is there?

    And for future releases is it possible to make it automatic in the plugin?

    Many many thanks!

    https://wordpress.org/plugins/all-in-one-seo-pack/

  2. wpsmort
    Support Manager at Semper Fi
    Posted 11 months ago #

    Hi solosails,

    No there is not a way to disable canonical URLs on a per page or post basis and I can't think of a use case for us adding this as a feature. What is your use case for this? If you're setting NOINDEX then the canonical URL really doesn't matter and it's ignored so there's no reason to remove it.

    We could probably provide you some custom code you could add for this, I'll ask our Lead Developer to respond.

  3. solosails
    Member
    Posted 11 months ago #

    Hi there wpsmort,

    There was a post by one of the Google team members (John Mueller) saying that you shouldn't mix rel=canonical and noindex

    http://www.seroundtable.com/noindex-canonical-google-18274.html

    However, if you guys think this is not a problem, I am more than happy to take your word for it.

    Personally, I can't see why there should be a problem, but I have recently suffered a MASSIVE hit from google going from first page to practically invisible about a month ago and I'm very keen to make sure that there is absolutely no excuse for Google to penalise me any more!

    Thanks, Andrew

  4. Peter Baylies
    Member
    Plugin Author

    Posted 11 months ago #

    Hi solosails,

    I don't think this really applies generally, as they're talking about using canonical urls as the equivalent of a redirect vs. using noindex to not show non-canonical pages. However, it's easy enough to support; add this code to a plugin or to the functions.php in your theme:

    global $solosails_noindex;
    $solosails_noindex = false;
    
    add_filter( 'aioseop_robots_meta', 'solosails_detect_noindex' );
    function solosails_detect_noindex( $robots ) {
        if ( strpos( $robots, 'noindex' ) !== false ) {
            global $solosails_noindex;
            $solosails_noindex = true;
        }
        return $robots;
    }
    
    add_filter( 'aioseop_canonical_url', 'solosails_noindex_canonical_urls' );
     function solosails_noindex_canonical_urls( $url ) {
            global $solosails_noindex;
            if ( $solosails_noindex ) return '';
            return $url;
    }
  5. solosails
    Member
    Posted 11 months ago #

    Hi Peter,

    Thanks once again for your amazing support.

    Do you think I should add this in or not? Currently I have tags set to noindex in an attempt to cut down duplicate content. And as mentioned this also has the canonical url listed as well.

    Very best regards, Andrew.

  6. Peter Baylies
    Member
    Plugin Author

    Posted 11 months ago #

    Give it a try; I don't think it's necessary, but it shouldn't hurt anything, as they're noindexed anyhow.

  7. solosails
    Member
    Posted 11 months ago #

    Great, thanks again.

Reply

You must log in to post.

About this Plugin

  • All in One SEO Pack
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic