There are three ways to implement hreflang:
- using link elements in the
- using HTTP header
- or using an
Each has its uses, so we’ll explain them and discuss which you should choose.
1. HTML hreflang link elements in your <head>
The first method to implement hreflang we’ll discuss is HTML hreflang link elements. And you do this by adding code like this to the <head> section of every page:
As every variation needs to link to every other variation, these implementations can become quite extensive and slow your site down. If you have twenty languages, choosing HTML link elements would mean adding twenty link elements as shown above to every page. That’s 1.5KB on every page load that no user will ever use but will still have to download. On top of that, your CMS will have to do several database calls to generate all these links. This markup is purely meant for search engines. That’s why I would not recommend this for larger sites, as it adds far too much unnecessary overhead.
2. hreflang HTTP headers
The second method of implementing hreflang is through HTTP headers. HTTP headers are for all your PDFs and other non-HTML content you might want to optimize. Georgia Phone Number Link elements work nicely for HTML documents, but not for other types of content as you can’t include them. That’s where HTTP headers come in and they should look like this:
An XML sitemap hreflang implementation
The third option to implement hreflang is using XML sitemap markup. It uses the
xhtml:link attribute in XML sitemaps to Georgia Phone Number add the annotation to every URL. It works very much in the same way as you would in a page’s
<link> elements. If you thought link elements were lengthy, the XML sitemap implementation is worse. To illustrate, this is the markup needed for just one URL with two other languages:
Having a lot of HTTP headers is similar to the problem with link elements in your
<head>: it adds a lot of overhead to every request.