Forum Moderators: Robert Charlton & goodroi
<a href="http://www.example.ca/" lang="fr" hreflang="fr">Example</a> Explanation of the above markup:
lang="fr" refers to the language used for the text between the anchor tags ("Example" in this instance), and hreflang="fr" refers to the language used on the linked page. The linked domain example.ca has a robots.txt exclusion so the entire site is not (and has never been) accessible to Googlebot. When searching for the linked domain in google.ca and set to English, the URL listing is in the following format:
Example - [ Translate this page ]
www.example.ca/ - Similar pages
I'm not aware of any other backlinks to the example.ca domain. So the SERP shows my link text as the page title (the actual page title is different, but is not available to Googlebot), and no snippet is shown as Googlebot doesn't know the page content. All this is standard stuff.
However, why does Google show the "Translate this page" link, correctly offering a French to English translation?
The only hypothesis I have is that Googlebot recognizes
hreflang="fr" in my link, because nothing else indicates the language used on the page, and the linking domain is not in the same language as the linked domain. Anyone else experienced this?
lang="fr" referring to the link text, and makes the assumption about the contents of the robots-excluded page from the language of the inbound link text, not the hreflang attribute. We do know that Google understands and uses lang at page-level, I think we can assume it will use it at individual element level too. Certainly the above example shows that it is useful to use the right markup when, for example, if you have links to different language versions of your site.