Typographical errors and underscores
Posted: Sun Dec 15, 2024 5:12 am
Both articles cited mention that simple typos in the language or country code are very common on international sites that try to implement hreflang.
Simple mistakes like using an invalid country code, using a country code without a language code, or even using an underscore (_) instead of a hyphen (-) can invalidate the hreflang attribute. However, in a 2017 Twitter exchange, Google Webmaster Trends Analyst Gary Illyes confirms that getting hreflang wrong shouldn’t cause Google any major complications, at least in theory.
I know he doesn't, but I still wanted to give you dbtodata my preferred version.
— Gary 鯨理/경리 Illyes (@methode) May 24, 2017
While there is some leeway in using GB and UK as country codes (because Google is smart), you should definitely aim to use the ISO 639-1 format for the language. If you use an incorrect abbreviation (for example, eng instead of en), Google will likely ignore it and the code will not work.
Don't use self-referencing hreflang
Another common problem is to add a self-referencing hreflang tag to the page. This means having an hreflang tag that refers to the language and country of the page itself as well as identifying other pages.
Ignoring Bing
Finally, if you want your international site to work on Bing, you need to follow their guidelines. There is a Bing webmastering article that explains how to tell Bing what your site’s language and country code is, but we feel it is outdated because the http-equiv=”content-language” meta tag it suggests has been considered bad practice since HTML5 was around .
Instead, the most useful advice is to specify the language of a page using lang= and to indicate the target audience with a content-language header.
Simple mistakes like using an invalid country code, using a country code without a language code, or even using an underscore (_) instead of a hyphen (-) can invalidate the hreflang attribute. However, in a 2017 Twitter exchange, Google Webmaster Trends Analyst Gary Illyes confirms that getting hreflang wrong shouldn’t cause Google any major complications, at least in theory.
I know he doesn't, but I still wanted to give you dbtodata my preferred version.
— Gary 鯨理/경리 Illyes (@methode) May 24, 2017
While there is some leeway in using GB and UK as country codes (because Google is smart), you should definitely aim to use the ISO 639-1 format for the language. If you use an incorrect abbreviation (for example, eng instead of en), Google will likely ignore it and the code will not work.
Don't use self-referencing hreflang
Another common problem is to add a self-referencing hreflang tag to the page. This means having an hreflang tag that refers to the language and country of the page itself as well as identifying other pages.
Ignoring Bing
Finally, if you want your international site to work on Bing, you need to follow their guidelines. There is a Bing webmastering article that explains how to tell Bing what your site’s language and country code is, but we feel it is outdated because the http-equiv=”content-language” meta tag it suggests has been considered bad practice since HTML5 was around .
Instead, the most useful advice is to specify the language of a page using lang= and to indicate the target audience with a content-language header.