DELTAWEB
All posts
Technical SEO

hreflang Implementation Methods: HTML, HTTP Header, Sitemap

Compare hreflang methods: HTML link tags, HTTP headers and XML sitemaps. Learn which fits each page type, its maintenance load and its error risk.

hreflang Implementation Methods: HTML, HTTP Header, Sitemap
8 minReading time
Arif KuruAuthor

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.

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.

CriterionHTML linkHTTP headerXML sitemap
Suitable file typeHTML pagesPDFs and non-HTML filesHTML pages and large URL sets
Maintenance ownerDevelopers and template teamServer and infrastructure teamSEO and technical team
ScalabilityHigh if the template is soundMedium; depends on rule countHigh; watch the 50,000 URL limit
Error detectionEasy in the page sourceRequires checking response headersRequires sitemap validation
Typical error riskWrong template variableCaching and redirectsMissing 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:

  1. HTML pages: HTML link tags, set at template level. Corporate, category and product pages are usually handled this way.
  2. Large catalogs and product sets: When page counts are high, an XML sitemap gives central control that does not depend on template errors.
  3. 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:

  1. On every release, sample the HTML, header or sitemap entries of the pages that changed.
  2. Run a weekly crawl to confirm that the return relationships still hold.
  3. Track indexing and page reports in Search Console for each language version.
  4. 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.

FAQ

Frequently Asked Questions

  • Which is the best hreflang method: HTML, HTTP header or sitemap?

    There is no single best method. HTML link tags suit HTML pages, HTTP headers suit PDFs and other non-HTML files, and XML sitemaps suit large URL sets. Pick one primary method for each URL set and use the others only where they are genuinely needed.

  • Where should HTML hreflang link tags be placed?

    They belong in the head section of the page, with one entry per alternate defining the rel alternate attribute, the hreflang value and the target URL. Because placement errors can silently break the signal, check the position before publishing. Language codes must also follow ISO 639-1.

  • How do I add hreflang to PDF files?

    For PDFs, hreflang information is delivered through the HTTP Link response header. The server must return rel alternate entries with hreflang values pointing to the alternate files. Verify the headers with a browser developer tool or a command-line request to confirm the server really sends them.

  • What should I watch for in an XML sitemap with hreflang?

    Declare the xhtml namespace on the root element and list every language alternate with xhtml:link inside each url entry. Each URL must also include itself. A single sitemap file may hold at most 50,000 URLs and may not exceed 50 MB uncompressed.

  • Can I use all three methods together?

    Technically yes, but it is not recommended for the same URL set. If one source is updated while another stays stale, the signals conflict. Splitting methods by page type ensures each URL is managed from a single source.

  • Which method increases maintenance load the most?

    The load depends on page count and how responsibilities are divided. A well-built template keeps HTML link maintenance low. Header rules become hard to manage as they multiply across the server layer, and a sitemap can become difficult once it holds thousands of entries. Clear ownership matters more than the method itself.

  • What happens if hreflang tags are written incorrectly?

    An incorrect language or region code can stop search engines from understanding which version to show, or cause the signal to be ignored altogether. A missing return entry can also invalidate the other alternates. Regular crawling and post-release checks are therefore essential.

  • How can I check the results of a hreflang setup?

    Inspect the page source, the HTTP response headers and the sitemap file separately. Then confirm in Search Console's index and page reports that each language version is indexed under the correct URL. Results can take several weeks to appear, so keep checking over that period.

Related Articles

No comments yet

Leave a Comment