- Feb. 16th, 2009
- 18 comments
has a bunch of tracking parameters on it, and therefore is duplicate … so we may cite a canonical URL in <head> to fix this —
In this case it is the only option to do so because Google Analytics requires the page be sent, so it is not an option to simply 301 to the canonical URL afterwards. Originally I had said it was; thanks to mark @ useyourweb for pointing this embarrassing lapse in reason to me. However, with regard to server-side campaign tracking (as would be the case in non-hosted Google Analytics as well), I still maintain that it is not ideal.
The real usefulness of rel=canonical is to deal with a different (and until now unsolvable problem). When I used to work for Barry Schwartz over at RustyBrick, I discussed with him at length how to deal with 1 product in 2 categories, while maintaining state (for breadcrumbs). So if we had 1 product in N categories, we end up with N URLs —
Barry and I never really came up with a solution we both liked 100%. Barry?
In my book, Search Engine Optimization with PHP, I recommend setting 1 category as primary, and then excluding the non-primary URLs with a SQL query. That was the best solution I'd mustered over the years.
So let's make http://www.example.com/Foo/My-Product.html Primary, and exlude the rest in robots.txt —
But the problem is that it basically throws some link-equity out the window. You can't stop people from linking to the non-canonical URLs … nor can you redirect because you need the state!
But now it would seem that we can use rel=canonical to resolve that problem. So we may simply place this in the head of the document —
But it's still better to use the good ol' 301 when possible. It's computationally cheaper for search engines, so I'd expect it to work better. And it's more proven. Certain redirects in Yahoo! have been screwy for years at a time. Why chance it?
"18 Wise Comments Banged Out Somewhere On The Internet ..."
When NOT To Use Canonical URL Links: Joost de Valk wrote a great WordPress plugin that I'm about to install. Fro.. http://tinyurl.com/dbcs39