Free Webinar: Website Migrations & Redirect Mapping Dos & Don’ts Sign up now!

Dealing with Indexability issues?

Crawl your website with Sitebulb for 300+ tech SEO checks

Try for Free
Critical This Hint requires immediate attention, as the issue may have a serious impact upon crawling, indexing or ranking. Issue This Hint represents an error or problem that needs to be fixed.

Canonical contains invalid HTML attributes

This means that the URL in question specifies a canonical element that contains the invalid HTML attributes hreflang, lang, media, or type.

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.

Google's documentation specifies that rel="canonical" annotation is ignored when it contains the attributes hreflang, lang, media, or type. That is because these attributes indicate the existence of alternate versions of a page, which conflicts with the meaning of the canonical tag.

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.

Examples that trigger this Hint:

Consider the URL: https://example.com/page-a

The Hint would trigger for this URL if the rel="canonical" tag contained the type attribute:

<head>
<title>Canonical with type</title>
<link rel="canonical" href="https://example.com/page-b" type="text/html"/>

...
</head>

Another example is if the rel="canonical" tag contained hreflang attributes:

<head>
<title>Canonical with hreflang</title>
<link rel="canonical" href="https://example.com/page-b" hreflang="en"/>

...
</head>

The Hint would also trigger for this URL if the canonical link element contained lang or media attributes in the same way.

How do you resolve this issue?

Consider whether your page is part of a set of duplicates or an alternate version of a page, optimized for a specific location, language, or device.

If your page is a duplicate, remove the invalid HTML attributes from your rel="canonical" element.

If your page is an alternate, remove the rel="canonical" element and use the appropriate HTML annotation.

Further Reading

Sitebulb Desktop

Find, fix and communicate technical issues with easy visuals, in-depth insights, & prioritized recommendations across 300+ SEO issues.

  • Ideal for SEO professionals, consultants & marketing agencies.

Sitebulb Cloud

Get all the capability of Sitebulb Desktop, accessible via your web browser. Crawl at scale without project, crawl credit, or machine limits.

  • Perfect for collaboration, remote teams & extreme scale.