The hreflang attribute allows you to show search engines what the relationship is between web pages in alternate languages. This becomes an important part of your SEO strategy when you offer websites in multiple languages to ensure you are not penalized for duplicate content, and so the search engine can serve relevant results to users searching in a given language (targeting).
To be effective, it is important to note that hreflang attributes must be implemented in the source code of your source site. If using the Smartling Global Delivery Network, we will propagate these attributes into the code of your localized sites so you get their full SEO benefits.
Placement of hreflang Attributes
There are 3 common ways the hreflang attribute can be placed on your website:
- using link elements in the <head>
- using HTTP headers
- or using an XML sitemap
Only use one of the above locations.
Link elements in the <head>
You can optimize your localized sites for search engines by adding HTML <link> tags in the head of your source pages, which will be duplicated on your localized pages automatically.
The hreflang attribute on each page should include a reference to itself (typically the english page), as well as to all the pages that serve as alternates for it:
<link rel="alternate" hreflang="en-us" href="https://www.company.com/graphs/" />
<link rel="alternate" hreflang="es-co" href="https://www.company.com/es_co/graficos/" />
<link rel="alternate" hreflang="es-us" href="https://www.company.com/es_us/graficas/" />
If you publish non-HTML files (like PDFs), you can use an HTTP header to indicate a different language version of a URL:
Link: <http://es.example.com/>; rel="alternate"; hreflang="es"
To specify multiple hreflang values in a Link HTTP header, separate the values with commas like so:
Link: <http://es.example.com/>; rel="alternate"; hreflang="es",<http://de.example.com/>; rel="alternate"; hreflang="de"
If you don't want to add the hreflang attribute to your on-page markup, you can provide this information to search engines via your sitemap. Google has a helpful guide to illustrate this process, or use this tool.
The hreflang attribute is one aspect of international SEO. Learn more about SEO strategy for your localized sites in the Search Engine Optimization section of our Help Center.