I've spent much time searching about the situation I'm in, before I post this question.

I have a poetry page (working for it currently) and I want users to be able to download poem in PDF, DOC, and TXT, But I don't want to have duplicate content issue, in any means, but also don't want to use no-follow for these files because I want search engines also now about it, because if someone searches for filetype:ext to find my pages.

I know I can set link canonical in head tag in .html version but how to do it for files?

To be clear poems are structured like this:

  • /poets/name-surname/poems/123.poem-title.htm this is main, next 3 versions are linked from this page, not from anywhere else.
  • /poets/name-surname/poems/123.poem-title.pdf this is the PDF version.
  • /poets/name-surname/poems/123.poem-title.doc is MS doc.
  • /poets/name-surname/poems/123.poem-title.txt is plain text.
  • Google does understand that there will be duplicate content between HTML pages and other file formats and is rather forgiving as this is normal, however, as for the best advice, I will leave that to someone else to answer.
    – closetnoc
    Jan 4, 2015 at 1:17
  • Thank you for the point, I'd love to know more about the solution technically
    – George G
    Jan 4, 2015 at 9:39

2 Answers 2


Google allows you to specify the canonical as an HTTP header. They give an example for canonicalizing one PDF file to another:

Link: <http://www.example.com/downloads/white-paper.pdf>; rel="canonical" 

This page shows how to use .htaccess to put these headers in. It would be:

RewriteRule ([^/]+)\.(pdf|doc|txt)$ - [E=FILENAME:$1]
<FilesMatch "\.(pdf|doc|txt)$">
    Header add Link '<http://www.example.com/poets/name-surname/poems/%{FILENAME}.htm>; rel="canonical"'

If these are not static files, it would be easier to output this header from your code. For example, in PHP you might use code like this before outputting the start of the document:

 header('Link: <http://www.example.com/poets/name-surname/poems/'.$poemid.'poem-title.htm; rel="canonical"');
  • Thank you, this will work even if they are not real existing files but run-time generated, also should I include these files in xml? or just leave it as it is now.
    – George G
    Jan 6, 2015 at 12:18
  • 1
    If your files are run-time generated, it would probably be easier to set the header in the code that generates the pages. For example, PHP can set the header: php.net/manual/en/function.header.php Jan 6, 2015 at 13:06
  • 1
    When you say "in XML" are you talking about an XML sitemap? Generally only the canonical URL needs to be included in an XML sitemap. In fact, including just one of the URLs in the sitemap is a signal to Google which to use as the canonical one, even in the absence of other canonicalization signals. See The Sitemap Paradox. Jan 6, 2015 at 13:08
  • Thank you for the great answer and help, yes I was talking about sitemap.
    – George G
    Jan 6, 2015 at 14:32

Alternate formats can be provided by link rel="alternate". For example:

<link rel="alternate" type="application/pdf" href="/poets/name-surname/poems/123.poem-title.pdf" title="PDF Version">

<link rel="alternate" type="text/plain" href="/poets/name-surname/poems/123.poem-title.txt" title="Text Version">

and so on.

Google also supports Link HTTP header for linking non-HTML alternatives to HTML one.

GET /poets/name-surname/poems/123.poem-title.pdf HTTP/1.1 Host: www.example.com

HTTP/1.1 200 OK Content-Type: application/pdf Link: <http://www.example.com/poets/name-surname/poems/123.poem-title.html>; rel="canonical"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.