• Resolved dm652

    (@dm652)


    Hi, I would like to know how to disable the self referencing canonical tag for a page where noindex has been set. It is technically wrong to have both in place so I guess there should be a workaround.

    thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello ??

    The tags aren’t mutually exclusive. One’s a directive, the other is suggestive.

    The canonical URL should always be ignored when it’s self-referencing. On the other hand, when it points elsewhere, then the search engine follows it. The robots-tag should then effectively be nullified. This is what might’ve been misinterpreted.

    In the end, this is self-deprecating. This falls in the realm of “over optimization”.

    With that out of the way, this is the filter you’ll want to use: the_seo_framework_rel_canonical_output
    You can empty its value and the canonical URL is omitted.

    Thread Starter dm652

    (@dm652)

    Hi, thanks for your fast response. I’m afraid that the filter solution does not work in this case because I’m looking for a way to disable canonical on a page basis, while the filter disables them completely on every page of the site.

    Regarding having both tags on the same page, I must disagree with you as there are experiments published online showing that if you have a page with a self-referencing canonical and then add a noindex tag they will NOT be deindexed, meaning that G will not honour the noindex tag if there was a self-referencing canonical in place first.

    The same experiment shows that, otherwise, if you add self-referencing canonical and noindex tag from the moment you create the page, they wont get indexed at all.

    Having the ability to disable canonical when there is a noindex in place seems very necessary in my opinion.

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi again ??

    Filters allow attaching of functions. In such a function, you can set conditions.

    This is what you’re looking for, although I don’t recommend using it for all the aforementioned reasons:

    add_filter( 'the_seo_framework_rel_canonical_output', function( $canonical_url ) {
    
    	$tsf = the_seo_framework();
    
    	$robots = $tsf->robots_meta();
    	if (
    		isset( $robots['noindex'] ) && $robots['noindex'] === 'noindex' // noindex is set.
    		&& $tsf->get_current_canonical_url() === $tsf->get_current_permalink() // The canonical URL points to the current page.
    	) return '';
    
    	return $canonical_url;
    } );
    

    I found that Google generally takes anywhere from a few minutes to half a year (depending on how popular the content is) to not only find but to utilize the updated meta tags thereafter. The latter is of most importance here.

    Now, I believe it’s more of an issue for Google to solve, rather than for us. In any case, time will fix this issue automatically.

    I think omitting the canonical URL will force Google to question its cache, and therefore they’ll reparse your page directly. Thanks for this valuable insight ??

    So, I’ve escalated this issue on GitHub:
    https://github.com/sybrew/the-seo-framework/issues/370

    Thread Starter dm652

    (@dm652)

    Thanks a lot for addressing this concern and sharing your points of view, very insightful. Fantastic support.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to disable canonical tag at page level when noindex is activated?’ is closed to new replies.