[Solved][AMP Error] The tag ‘link rel=canonical’ appears more than once in the document.

We received a sudden rise of errors in Search Console with Error
“The tag ‘link rel=canonical’ appears more than once in the document”.
We are using the following two plugins:

This Error arose because both plugins were adding canonical to AMP Code. Removing one is the only solutions.

As Canonical from Yoast was wrong, we decided to remove Yoast’s Canonical. Thanks to Yoast team for the canonical documentation & wpseo_canonical Filter. Following Code is what we used to remove Canonical from AMP Output.

// Remove canonical from better-amp output.
add_filter( 'wpseo_canonical', 'remove_canonical_from_bamp' );
function remove_canonical_from_bamp( $canonical ) {
      return false;
  return $canonical; /* Do not remove this line. */

Above code will work only if you are having Better AMP plugin in use.
Happy Publishing!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.