What does hreflang tell Google?
According to Google Search Central, hreflang tells Google about versions of the same content intended for different languages or regions. Google Search uses this information to help users find the page version that best matches their language or region. Google Search Central: Localized versions of pages
You can use this markup for pages whose content has been fully translated into multiple languages. It also works for versions in the same language that share similar content but differ in regional details. Google also gives the example of pages where the main content stays in the same language and only template elements such as navigation and footers are translated.
According to Google, localized page versions are considered duplicates only when the main content remains untranslated. Google uses algorithms to determine a page's language and does so independently of hreflang and the HTML lang attribute.
URLs for language versions
Google recommends giving each language version of a page its own URL. This avoids relying on cookies or browser settings to change the language of the content at a single URL. With separate URLs, hreflang annotations help Google Search results link to the appropriate language version. Google Search Central: Multi-regional and multilingual sites
If you change content dynamically based on language settings or redirect users to another URL, Google may miss some versions when it discovers and crawls your pages. Googlebot typically crawls from the United States and leaves the Accept-Language header unset in HTTP requests.
Google also recommends avoiding automatic redirects between versions based on a user's presumed language. These redirects can prevent users and search engines from seeing all versions of the site. Links to the other language versions of a page let users choose the version they prefer.
Three markup methods
Google supports three ways to indicate language and regional versions: HTML, HTTP headers, and sitemaps. Google treats these methods as equivalent, so you can choose whichever suits your site. Using all three offers no additional benefit in Search and can make the implementation harder to manage.
Whichever method you use, each language version must list itself and the other language versions. Alternate URLs must be fully qualified, including http or https. The alternate versions can be on different domains.
If two pages fail to point to each other, Google ignores those annotations. If maintaining a complete set of reciprocal links becomes difficult, you can omit some languages on some pages. Google will still process the versions that point to each other. Google emphasizes adding reciprocal links between newly added language pages and the corresponding versions in the original or dominant language.
hreflang in HTML
With the HTML method, add a set of <link> tags to the <head> of each page version. The set includes a link to every version, including the page itself. Use the same set of links on every version of the page. Google says this method is useful when you have no sitemap or cannot set HTTP response headers.
Each link includes the rel="alternate", hreflang, and href attributes. The hreflang attribute contains a supported language or region code or the x-default value. The href attribute contains the full URL of the corresponding version. Google shows the following format:
<link rel="alternate" hreflang="lang_code" href="url_of_page" />
The <link> tags must appear inside a well-formed HTML <head> section. If you're unsure, Google suggests pasting the generated page HTML into an HTML validator to confirm that the links are inside the <head>. Google also advises against combining hreflang annotations with other attributes such as media in the same <link> tag.
Google's example includes generic English, UK English, US English, and German versions, along with a default page that targets no specific language or region. Every page in the example includes the same links in its <head>:
<head>
<title>Widgets, Inc</title>
<link rel="alternate" hreflang="en-GB"
href="https://en-gb.example.com/page.html" />
<link rel="alternate" hreflang="en-US"
href="https://en-us.example.com/page.html" />
<link rel="alternate" hreflang="en"
href="https://en.example.com/page.html" />
<link rel="alternate" hreflang="de"
href="https://de.example.com/page.html" />
<link rel="alternate" hreflang="x-default"
href="https://www.example.com/" />
</head>
Google does not use the language-specific subdomain names in the example to determine each page's intended audience. You must specify which audience each version targets. The default page in the example lets users choose their language and region.