Imagine an exporter whose German, French and British pages carry the same product information. Google still has to decide which version to show which user, and the signal that answers that question is the hreflang tag. Where you place it, in the HTML head, in an HTTP header or in an XML sitemap, is not just a technical preference. It directly shapes your maintenance load and your error risk. If you are new to the concept, start with our guide to what hreflang is and why it matters. Here we compare the three methods side by side and use a decision table to show which one fits which page type.
Key Takeaways
- HTML link tags are the most common and most readable method for HTML pages, managed in each page's head.
- HTTP headers are the practical, often only, option for PDFs and other non-HTML files.
- XML sitemaps manage large URL sets centrally, but become harder to debug as the file grows.
- All three methods follow the same return rule: every alternate must point back, and each page must list itself.
- Choose by page type, URL volume and the team's ability to maintain it. No single method fits every case.
The shared logic behind all three methods
All three methods do the same job: they tell search engines that a set of URLs are language or region equivalents of one another. Each method carries three pieces of information: which URL applies to which language-region code, and the list of alternates for that URL. The syntax differs, but the rules do not. The language code must follow ISO 639-1, and the optional region code must follow ISO 3166-1 alpha-2, for example en, en-gb or de-de. For the details of codes, read our article on hreflang language and region codes.
There is also the x-default value. It points to the fallback page shown when no language or region alternative matches the user. For usage patterns and common mistakes, see our x-default explainer.
Method 1: HTML link tags
The most common approach is to add <link> tags to the <head> of each HTML page. The example below shows four alternates for a home page on a fictional domain (ornek.com):
<link rel="alternate" hreflang="tr" href="https://www.ornek.com/tr/">
<link rel="alternate" hreflang="en" href="https://www.ornek.com/en/">
<link rel="alternate" hreflang="de" href="https://www.ornek.com/de/">
<link rel="alternate" hreflang="x-default" href="https://www.ornek.com/">
The advantage is that the tags sit right next to the page content. When a team edits a page, the related tags come into view as well. The drawback is that every language version must list all alternates on every page. In a catalog of hundreds of pages, this has to be solved at template level, not by hand.
Strengths of the HTML method
- Tags are visible in the page source, so developers and SEO specialists can check them in the same place.
- One change to the CMS template propagates to every page that uses that template.
- Debugging is simple: spotting a missing alternate in the source takes seconds.
Weaknesses of the HTML method
- If the template is fed the wrong variables, language versions can point to each other's URLs.
- It cannot be used for PDFs, downloadable files or other non-HTML resources.
- As page counts grow, checking the consistency of the tag set by hand becomes impossible.
Method 2: HTTP headers
With the HTTP header method, the hreflang information travels in the Link header of the server response. The domain in the example below is fictional as well:
Link: <https://www.ornek.com/de/katalog.pdf>; rel="alternate"; hreflang="de",
<https://www.ornek.com/en/catalog.pdf>; rel="alternate"; hreflang="en"
Its real value is that it works for non-HTML files such as PDFs, where it is often the only practical option. For a step-by-step setup, see our article on adding hreflang to PDFs via HTTP headers.
Risks of the HTTP header method
Headers are usually set at the server, application or CDN layer, which means the content team cannot see or change them directly. When a redirect rule changes, or when a cache layer stores a different response, the hreflang signal can disappear silently. If you choose this method, keep the header rules under version control and check the actual response headers after every release.
Method 3: XML sitemaps
The third method collects hreflang data in an XML sitemap. Under each <url> entry, all language alternates of the same URL set are written as xhtml:link elements. The root element must declare xmlns:xhtml="http://www.w3.org/1999/xhtml".
<url>
<loc>https://www.ornek.com/en/product/valve/</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://www.ornek.com/en/product/valve/"/>
<xhtml:link rel="alternate" hreflang="tr" href="https://www.ornek.com/tr/urun/vana/"/>
<xhtml:link rel="alternate" hreflang="de" href="https://www.ornek.com/de/produkt/ventil/"/>
</url>
The biggest advantage of the sitemap method is central control. All language relationships live in one file and can be updated without touching page templates. Each URL, however, must also list itself in its own entry. A sitemap file may contain at most 50,000 URLs and may not exceed 50 MB uncompressed; large sites split their URLs across several sitemap files tied together by a sitemap index. For the implementation logic, see our guide to implementing hreflang via XML sitemaps.
Common sitemap mistakes
- A URL that is missing from its own xhtml:link set.
- A language version added to the sitemap while its counterpart page is not in the sitemap at all.
- The sitemap falling out of sync with live pages because nobody updated it after a release.
Comparison table
Placing the three methods side by side, the choice usually comes down to four criteria: file type, URL volume, maintenance ownership and ease of error detection.
| Criterion | HTML link | HTTP header | XML sitemap |
|---|---|---|---|
| Suitable file type | HTML pages | PDFs and non-HTML files | HTML pages and large URL sets |
| Maintenance owner | Developers and template team | Server and infrastructure team | SEO and technical team |
| Scalability | High if the template is sound | Medium; depends on rule count | High; watch the 50,000 URL limit |
| Error detection | Easy in the page source | Requires checking response headers | Requires sitemap validation |
| Typical error risk | Wrong template variable | Caching and redirects | Missing return entry |
Choosing by page type
In practice most sites do not stick to a single method. The order below is a solid starting point for teams that want to keep maintenance low:
- HTML pages: HTML link tags, set at template level. Corporate, category and product pages are usually handled this way.
- Large catalogs and product sets: When page counts are high, an XML sitemap gives central control that does not depend on template errors.
- PDFs and downloadable files: HTTP headers are the one practical method.
A hypothetical example
Consider a valve manufacturer (a hypothetical example) that publishes several hundred product pages in Turkish, English and German. If corporate pages use HTML link tags and product sets are managed through a sitemap, a template change will not break product pages, and the control sits in one file. The catalog PDFs are then flagged with HTTP headers. This is only an illustration; the right split on your site depends on your page types and team structure.
A checklist to reduce error risk
Whichever method you choose, run the following checks before and after each release:
- Every alternate must list itself and all other alternates (the return rule).
- Language codes must follow ISO 639-1, and region codes ISO 3166-1 alpha-2.
- The same language-region value must not be declared more than once for the same URL.
- Every declared URL should return a direct 200 response; redirected URLs create signal confusion.
- Canonical tags and hreflang targets must not conflict. Each alternate should be canonical to itself.
To debug return tag problems, follow the steps in our return tag errors guide.
Common misconceptions
"Using all three methods at once is safer"
It is not. Using several methods for the same URL set creates conflicting signals whenever one source is updated and another is left stale. Pick one primary method and use the others only where they are genuinely needed.
"The sitemap method always produces the fastest results"
Speed depends on when the search engine re-reads the relevant file, and it cannot be guaranteed. Do not assume a method is faster. Judge it by watching index status after each change.
Monitoring after launch
Whichever method you use, a hreflang setup should not be configured once and forgotten. Four steps make a sound starting routine:
- On every release, sample the HTML, header or sitemap entries of the pages that changed.
- Run a weekly crawl to confirm that the return relationships still hold.
- Track indexing and page reports in Search Console for each language version.
- When a new market is added, confirm that all three methods, wherever used, are updated for the same URL set.
Conclusion and next step
The right hreflang method is chosen by page type, URL volume and the team's capacity to maintain it. For HTML pages, template-level link tags are the sound default. For large catalogs, sitemaps are the natural fit, and for PDFs, HTTP headers are the most sensible starting point. Apply the decision table in this article to your own page types and name a clear owner for each method.
As a next step, list the page types on your site that carry hreflang, assign each one a method from the options above, and record the result of your first check. Once it is clear who updates what, method selection becomes a stable routine rather than a one-off decision.




No comments yet
Leave a Comment