Monday, December 23, 2024

Google Warns Of Quirk In Some Hreflang Implementations

Must read

Google updated their hreflang documentation to note a quirk in how some websites are using it which (presumably) can lead to unintended consequences with how Google processes it.

hreflang Link Tag Attributes

<link> is an HTML attribute that can be used to communicate data to the browser and search engines about linked resources relevant to the webpage. There are multiple kinds of data that can be linked to such as CSS, JS, favicons and hreflang data.

In the case of the hreflang attribute (attribute of the link element), the purpose is to specify the languages. All of the link elements belong in the <head> section of the document.

Quirk In hreflang

Google noticed that there is an unintended behavior that happens when publishers combine multiple in attributes in one link element so they updated the hreflang documentation to make this more broadly known.

The changelog explains:

“Clarifying link tag attributes
What: Clarified in our hreflang documentation that link tags for denoting alternate versions of a page must not be combined in a single link tag.

Why: While debugging a report from a site owner we noticed we don’t have this quirk documented.”

What Changed In The Documentation

There was one change to the documentation that warns publishers and SEOs to watch out for this issue. Those who audit websites should take notice of this.

This is the old version of the documentation:

“Put your <link> tags near the top of the <head> element. At minimum, the <link> tags must be inside a well-formed <head> section, or before any items that might cause the <head> to be closed prematurely, such as <p> or a tracking pixel. If in doubt, paste code from your rendered page into an HTML validator to ensure that the links are inside the <head> element.”

This is the newly updated version:

“The <link> tags must be inside a well-formed <head> section of the HTML. If in doubt, paste code from your rendered page into an HTML validator to ensure that the links are inside the <head> element. Additionally, don’t combine link tags for alternate representations of the document; for example don’t combine hreflang annotations with other attributes such as media in a single <link> tag.”

Google’s documentation didn’t say what the consequence of the quirk is but if Google was debugging it then that means it did cause some kind of issue. It’s a seemingly minor thing that could have an outsized impact.

Read the newly updated documentation here:

Tell Google about localized versions of your page

Featured Image by Shutterstock/Mix and Match Studio

Latest article