Reputation: 191729
At least Google supports the <link rel="canonical">
tag and the Link HTTP Header to canonicalize URLs and help prevent duplicate content.
Is there a preference to using the HTML tag over the HTTP header when it is available? On my site I'd like to create a simple function that lets you set the canonical URL, but for non-HTML pages this can only be done by the header of course.
So is it okay to only depend on the HTTP header for setting canonical URLs?
Upvotes: 0
Views: 595
Reputation: 2880
Using the meta tag is useful when your page is completely out of context (an HTML file on an FTP server (which Google can also index)). The header is best for anything transported over HTTP (as you don't have to parse the body and rely on the ~validity of the document).
Upvotes: 2