Search Engine Optimization

Implementing hreflang Attributes

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).

Where to Place the hreflang Link Tag Block

The hreflang attribute can be placed in the on-page markup, the HTTP header, or the sitemap. Only use one of those locations.

On-page Markup

You can optimize your localized sites for search engines by adding HTML <link> tags in the header 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/" />

Sitemap

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.

HTTP Header

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"

Visit Google Search Console Help or Moz for additional help with the hreflang attribute.

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.

Was this article helpful?