Canonical contains superfluous HTML attributes
This means that the URL in question specifies a canonical element that contains attributes other than rel and href.
Why is this important?
Canonical annotations are meant to help search engines determine what page is canonical when a set of duplicates exists. When properly implemented, search engines will only index the canonical URL.
Attributes other than rel and href in canonical elements are ignored by Google. Canonical tags should only include relevant attributes, to ensure an effective indexing strategy.
Specific attributes that do lead to the whole canonical tag being dismissed are flagged up by the hint 'Canonical contains invalid HTML attributes.'
What does the Hint check?
The hint will trigger for any URL that specifies a canonical link element containing HTML attributes that will cause the canonical annotation to be ignored, specifically hreflang, lang, media, or type.
This hint will trigger for any URL with canonical link elements containing anything other than rel='canonical' and href='URL' attributes. According to a study by Merj, the most common superfluous attributes in canonical tags are:
- data-react-helmet
- itemprop
- data-n-head
- data-rh
- id
- data-senna-track
- data-hid
- data-baseprotocol
- data-basehost
- class
Examples that trigger this Hint:
Consider the URL: https://example.com/page-a
The Hint would trigger for this URL if it the rel="canonical" tag contained the data-testid attribute:
Why is this Hint marked 'Potential Issue'?
This Hint is classified as a 'Potential Issue', since most attributes won't stop search engines from recognizing canonical link tags.
To adhere to best practice, simplify your canonical link tags, avoiding any unnecessary attributes.
If your canonical tag contains additional attributes, regularly verify the effectiveness of your tags using Google Search Console or Bing's Webmaster Tools.