On this page
During a documentation refresh, the same PDF may be available at an old download URL and a new documentation URL. A canonical URL for a PDF can be expressed in an HTTP Link response header, allowing the server to identify the preferred URL without changing the PDF itself.
This guide shows how to configure and inspect that header, and how to check for conflicting signals. Verification limitation: Google’s current canonicalization guidance, search-engine support, and the relevant HTTP specifications were not retrieved for this article. Verify the guidance for each search engine you care about before relying on the header for indexing decisions.
Key Takeaways
- Send
Link: <preferred-URL>; rel="canonical"in the HTTP response for a duplicate PDF. - An HTTP header is separate from an HTML
<link rel="canonical">element; a PDF normally cannot use the HTML element in its response body. - Inspect redirects and the final PDF response. A header on an intermediate redirect is not a substitute for checking the final response.
- Keep redirects, canonical headers, internal links, and sitemaps consistent where practical. A canonical signal does not guarantee indexing or selection of the preferred URL.
Choose the preferred document URL
Suppose a documentation refresh leaves two public URLs serving the same report:
- Preferred:
https://www.example.com/docs/report.pdf - Duplicate:
https://www.example.com/downloads/report.pdf
These are fictional example URLs; replace them with URLs on your own site. Choose a stable preferred URL that serves the intended document successfully. If the files differ substantially—for example, one is an older edition—decide whether they should remain independently discoverable rather than treating them as duplicates.
For the duplicate response, the canonical header would identify the preferred URL:
Link: <https://www.example.com/docs/report.pdf>; rel="canonical"
The angle brackets enclose the target URL; rel="canonical" identifies the relationship. Use an absolute URL to make the intended target clear. The preferred PDF can also send a self-referencing canonical header.
This header is response metadata. By contrast, an HTML canonical element appears inside an HTML document, typically in its <head>. Adding an HTML element to a separate landing page does not itself add a canonical header to the PDF response.
Advertisement
Configure the PDF responses
How you add the header depends on whether the PDF is served by your web server, application, storage provider, or CDN. Configure the component responsible for the response that readers and crawlers actually receive.
The following is an illustrative Nginx configuration, not a complete server configuration. It assumes the two files exist under /var/www/site at the paths shown and contain the same document:
location ~ ^/(docs|downloads)/report\.pdf$ {
root /var/www/site;
try_files $uri =404;
add_header Link '<https://www.example.com/docs/report.pdf>; rel="canonical"';
}
On successful PDF responses, the intent is for both URLs to send the same canonical target. Integrate the rule into your existing configuration rather than pasting it blindly: other location rules, inherited headers, rewrites, and a CDN can change the final response. Validate your configuration using your normal Nginx deployment process, then inspect the public URLs. This example was not executed or checked against current Nginx documentation for this article.
If the old URL no longer needs to serve the PDF directly, a permanent redirect to the preferred URL may be a simpler consolidation approach. Check that the redirect goes to the intended final URL and that the final resource is accessible. Redirects and canonical headers are different mechanisms; do not assume that adding one removes the need to inspect the other.
Inspect redirects and the final PDF response
Use curl from a machine that can reach the public site. First, inspect the original URL without following redirects:
curl -sS -D - -o /dev/null 'https://www.example.com/downloads/report.pdf'
Then follow redirects and print the response headers for each hop:
curl -sS -L --max-redirs 10 -D - -o /dev/null 'https://www.example.com/downloads/report.pdf'
Finally, inspect the preferred URL directly:
curl -sS -L --max-redirs 10 -D - -o /dev/null 'https://www.example.com/docs/report.pdf'
Replace the example URLs before running these commands. They make GET requests, discard the response bodies, and print headers; they do not save the PDF. The redirect-following commands can show multiple response blocks. Review them in order:
- Check the status and any
Locationheader at each redirect. - Find the final response block and confirm that it successfully serves the intended PDF.
- On a duplicate PDF served directly, look for a
Linkheader whoserel="canonical"target is the preferred URL. - Check the preferred URL’s final response for a conflicting canonical target. If it has a self-referencing header, confirm that the URL matches the final preferred URL.
- Check the final
Content-Typeand, when necessary, download and open the file separately to confirm that it is the intended document.
A HEAD request, such as curl -I, can be convenient, but compare it with GET if headers differ: intermediaries or server configuration can handle the methods differently. Also check the public response after CDN or cache changes have propagated; inspecting only an origin server may miss what visitors receive.
Advertisement
Resolve conflicting signals
Inventory the PDF URLs exposed by old documentation, navigation, downloads pages, and sitemaps. For each one, record whether it serves a PDF, redirects, or fails, and identify its final destination. Then align the signals you control:
- Point internal links and sitemap entries at the preferred URL where practical.
- If a duplicate remains accessible, avoid sending a canonical header that names a different preferred URL from the one used elsewhere.
- Avoid canonical chains, such as an old PDF naming a second URL that then names a third. Use the intended final URL directly.
- Check that the canonical target is not an error page, an unintended redirect, or a materially different document.
- Review headers added at multiple layers. An origin and a CDN can otherwise send conflicting
Linkvalues.
A canonical declaration is a signal, not a guarantee that a search engine will index a document or select the nominated URL. Search engines may evaluate other signals or apply their own rules. Consult their current documentation and use their inspection tools, where available, to investigate the outcome.
Common Mistakes
- Checking only the redirect. The final PDF response may have no canonical header, or a different one.
- Editing only the landing page. Its HTML canonical element describes that page; it does not configure the PDF’s HTTP response.
- Treating different editions as duplicates without review. Readers may need both documents, and their content may not be equivalent.
- Trusting an origin-only test. A cache, CDN, or proxy can alter the public response.
- Assuming the signal forces indexing. Verify both accessibility and the search engine’s observed choice.
Best Practices
Keep a small URL inventory during the refresh, test both old and preferred URLs after deployment, and repeat the check after changes to hosting or caching. If the files are not public, use an authorized environment and avoid exposing private document URLs in third-party inspection tools.
Conclusion
A canonical Link response header gives you a way to identify a preferred URL for a duplicate PDF without editing its contents. Configure the public response, inspect every redirect and final response, and keep other URL signals aligned. Verify current search-engine support before treating the header as part of your indexing strategy.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.