DELTAWEB
All posts
Technical SEO

PDF hreflang: Adding Language Tags via HTTP Headers Guide

How to add hreflang to PDFs with HTTP Link headers: sample header lines, server setup, validation steps, common mistakes and a checklist for exporters.

PDF hreflang: Adding Language Tags via HTTP Headers Guide
8 minReading time
Arif KuruAuthor

Picture an exporter who has published its product catalog as three separate PDF files: Turkish, English and German. When a buyer in Germany searches for a catalog, how does Google know which file to show? On web pages, hreflang annotations usually sit in the head section as link elements. A PDF has no head section, so the route Google documents for non-HTML files is the HTTP response header, specifically a Link header. The catalog scenario below is a hypothetical example, but the method is real and works for any downloadable file. If hreflang is new to you, start with our what is hreflang guide.

Key Takeaways

  • For non-HTML files such as PDFs, hreflang is delivered in the HTTP Link response header.
  • Every language version must list all sibling versions and itself. A one-way list is not enough.
  • Use absolute URLs and valid ISO language codes in every entry.
  • Configure headers at the server or CDN layer, then verify them with curl rather than a browser.
  • Choose between header, HTML and sitemap methods case by case; this article could not confirm sitemap support for PDFs.

Why PDFs need a different approach

Hreflang is a signal that tells search engines which language or regional version of the same content exists. On web pages it is usually expressed with link elements in the head section. A PDF has no such head section, so the signal has to travel outside the file, in the HTTP headers the server sends when it delivers the file. This matters for catalogs, technical data sheets, certificates and price lists, which are often distributed as downloads.

There is an important distinction here. Language information inside the file does not do the same job as hreflang. Hreflang establishes the relationship between versions. Assuming that the language written inside a document replaces hreflang is one of the most common misunderstandings. The second frequent mistake is adding a header to a single language file and considering the job done. Hreflang requires reciprocity: every file has to point back to the others.

The HTTP Link header is a standard response header used to describe resources related to the current one. Google supports adding rel="alternate" and hreflang parameters to it. The basic form looks like this:

Link: <https://www.example.com/downloads/katalog-en.pdf>; rel="alternate"; hreflang="en"

The URL in angle brackets is the full address of the target version. Parameters are separated by semicolons, and the language value is wrapped in quotes. To list several versions, entries are joined with commas. The HTTP standard also allows the same header to be sent more than once, and both forms produce the same result. What matters is that each language version includes all sibling versions in its own response.

Syntax rules

The language value starts with an ISO 639-1 language code. Optionally, an ISO 3166-1 Alpha-2 country code can follow, for example en-gb or de-de. Do not confuse the two: for the United Kingdom the correct value is en-gb, not en-uk. If there is no regional difference, a language code alone is enough, and for most catalogs that is the cleaner choice.

The x-default value

When no version matches the user's language, the default version is marked with x-default. The same logic applies to PDFs. For example, you can designate the English file as the general fallback. For the details, see our x-default guide.

Sample header lines

For our hypothetical exporter, which publishes its catalog in three languages, the response header of the English file could look like this:

Link: <https://www.example.com/downloads/katalog-en.pdf>; rel="alternate"; hreflang="en",
<https://www.example.com/downloads/katalog-de.pdf>; rel="alternate"; hreflang="de",
<https://www.example.com/downloads/katalog-tr.pdf>; rel="alternate"; hreflang="tr",
<https://www.example.com/downloads/katalog-en.pdf>; rel="alternate"; hreflang="x-default"

The same list is repeated word for word in the German and Turkish files. The list must be complete and identical in every file. Only the file's own address stays the same, and it is already part of the list. Forgetting to include the file's own URL is a common error; in Google's examples, every version lists itself as well.

In this example example.com is a placeholder domain. In a real deployment, all addresses should live on your canonical domain and use HTTPS.

Server setup

Headers are defined at the layer that serves the file, either the origin server or the CDN. The examples below do not perform redirects; they only add headers. Syntax can differ slightly between server versions, so test in a staging environment first.

Apache

Apache requires the mod_headers module to be enabled. The block below adds headers to PDF files whose names start with katalog:

<FilesMatch "katalog-.*\.pdf$">
  Header add Link "<https://www.example.com/downloads/katalog-en.pdf>; rel=\"alternate\"; hreflang=\"en\""
  Header add Link "<https://www.example.com/downloads/katalog-de.pdf>; rel=\"alternate\"; hreflang=\"de\""
</FilesMatch>

Nginx

In Nginx, the add_header directive works in the location block where it is defined. Headers defined in a parent block are not inherited once a child block declares its own add_header. For that reason, write all Link lines for the PDF location together:

location ~* katalog-.*\.pdf$ {
  add_header Link "<https://www.example.com/downloads/katalog-en.pdf>; rel=\"alternate\"; hreflang=\"en\"";
  add_header Link "<https://www.example.com/downloads/katalog-de.pdf>; rel=\"alternate\"; hreflang=\"de\"";
}

CDN and cache notes

If files are served through a CDN, test whether the edge keeps the headers intact. Some setups rewrite or strip response headers at the edge. After changing headers, purge the cache and confirm that old responses are no longer returned. WordPress teams may face a separate issue with PDFs in the media library; our WordPress hreflang setup guide covers the approach to take there.

Validation steps

After publishing the headers, check them from the command line rather than a browser, because browsers do not display every response header. On Windows, curl.exe works in PowerShell or Git Bash. The checklist is:

  1. Fetch the headers: run curl.exe -I https://www.example.com/downloads/katalog-en.pdf and read the response headers.
  2. Check the status code: the response should be 200. If the file redirects or lands on a login page, search engines cannot reach it.
  3. Verify absolute URLs: every Link entry needs the scheme and full domain.
  4. Check reciprocity: each language file must include all sibling versions and itself. A missing return link can cause the signal to be ignored.
  5. Review language codes: case does not matter, but an invalid code such as en-uk is not valid.
  6. Avoid canonical conflicts: each language file should declare its own URL as canonical.

All of these checks can be done at the header level. To observe real search behaviour, you can also use the URL Inspection tool in Search Console. We could not confirm whether Search Console offers a dedicated report for PDF hreflang at the time of writing, so rely on header testing rather than waiting for a report. Google's documentation can change over time; review the current page before implementing.

Common mistakes

The table below summarises the most frequent problems in PDF hreflang implementations and the first corrective steps.

MistakeSymptomFix
Missing return linksEach file lists the others, but some do not list themselvesAdd the complete list, including the file's own URL, to every file. See our return tag errors guide for details.
Relative URLsA Link entry starts with a slashWrite absolute URLs with scheme and domain.
Wrong language codeCountry codes such as en-uk are used incorrectlyUse an ISO 639-1 language code and, where needed, an ISO 3166-1 country code.
Redirect chainsA listed file returns 301 to another addressMake sure every listed URL returns 200 directly.
Header on only one fileA signal exists for one language but not the othersApply the configuration to all language files and test each one.
Edge cache strips the headerThe header is present at origin but missing on the public addressReview the CDN rule and purge the cache.

Sitemaps and HTML alternatives

For HTML pages, hreflang can be set with head elements, sitemaps or HTTP headers. For PDFs, most teams prefer headers, because they define the relationship without touching the file's content. We could not confirm in this article whether Google supports hreflang for PDFs through sitemaps, so check the current Google documentation before relying on that method. You can compare the three approaches in our implementation methods guide.

A practical rule of thumb: if the file sits next to an HTML landing page, use HTML hreflang on that page and also add headers to the PDFs. If the file is distributed on its own, headers are the only option. Which method fits best depends on your team's technical setup and should be decided together with the people who maintain the server.

Conclusion and next step

For PDFs, hreflang is delivered through the HTTP Link header, and for it to work every language version must list all sibling versions and itself. Start by writing sample headers for one catalog, test them with curl.exe -I, and then roll the approach out to the other files. Before writing any header, list which languages each catalog exists in and the exact address of each file; deciding which file belongs to which language is the most valuable first step. If you would like help building that list with your team, you are welcome to get in touch.

FAQ

Frequently Asked Questions

  • Can hreflang be added to PDF files?

    Yes. Google's documented method for non-HTML files such as PDFs is to deliver hreflang information in an HTTP Link response header. Each language version must list all sibling versions and itself in its header. The details are covered in the sections above.

  • What is an HTTP Link header?

    Link is a standard HTTP response header that describes resources related to the current one. In the hreflang context it is used with rel="alternate" and hreflang parameters. The header is sent when the file is delivered and is usually not visible in the browser.

  • Where is the hreflang header for a PDF defined?

    On Apache it is set with Header add Link, and on Nginx with add_header Link, scoped to the file path. If a CDN sits in front, confirm that the edge keeps the headers. The header should be identical at the origin server and on the public address.

  • Is x-default used with PDF hreflang?

    Yes. When no version matches the user's language, a hreflang="x-default" entry can point to the fallback file. This entry belongs in the same list as the others and must use an absolute URL. The general logic is explained in the x-default guide.

  • How do I verify the header?

    Run curl.exe -I against the PDF address and read the Link lines. Confirm the status code is 200, the addresses are absolute, and every file lists all versions. Browsers hide some headers, so command-line testing is more reliable.

  • Can I define PDF hreflang in a sitemap?

    We could not confirm in this article that sitemap-based hreflang is supported for PDFs. Check Google's current hreflang documentation for the definitive answer. In practice the header method is the most explicit way to define relationships without modifying the file.

  • What happens if PDF hreflang is implemented incorrectly?

    Faulty lists can make it harder for search engines to match language versions correctly, and the wrong-language file may appear for a given audience. Missing return links are one of the most common causes. When a problem appears, test the headers first and then correct the list.

  • How should hreflang work alongside canonical tags?

    Each language file should declare its own URL as canonical. Pointing the canonical of one language file to a different language file conflicts with the hreflang signal. Plan canonical and hreflang decisions together, in the same table and at the same time.

Related Articles

No comments yet

Leave a Comment