I wonder if anyone has found a way to use canonical url on a drupal site. I tried solution with Nodewords 6.x-1.x-dev but it by default puts meta tag canonical to every page so if it's not specified it defaults to homepage, so it is useless for now.
Then I tried patched version of Global Redirect but it just adds url specified as path alias to meta canonical tag. That's not practical. We should be able to use both functions (url alias and canonical url) simultaneously and if canonical url is not specified for particular page, then the header should be without canonical tag on that page.
I considered trying Global Redirect module from Yoast.com but I have read some comments that it behaves the same as patched version of that module from Drupal.org.
Did anyone find useful solution for this? It is been more than 4 months since the big three search engines announced support for this tag.
Comments
...
Global Redirect does a 301 redirect which is a more powerful way of telling search engines what the canonical url is, unless you are wanting something that can handle query strings, then I can see this would be very useful.
Not sure what you mean by "We should be able to use both functions (url alias and canonical url)".
If you are using alias's then surely that is the one you want to be canonical - they're one and the same thing.
FYI its not a meta tag as far I know, its a link tag with a rel attribute. E.g.
<link rel=”canonical” href=”http://www.example.com/my-example-node”/>Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Thanks for the correction, it
Thanks for the correction, it is not meta tag.
We should be able to use both simultaneously in situation if we want the same product description to be available under different categories and while it is visited under one category if we don't want redirect to another category. Example:
web development/cms/drupal-review
and
software/reviews/drupal-review
There are numerous examples like this.
In this situation I would like both urls to have the same content, and I want visitors to be able to visit them without redirection from one of those categories to another. So, I want to create two nodes with identical content, redirected by url alias to its own url, but I want to tell search engines which url is canonical to avoid having duplicate content. That is the purpose and main initiative behind canonical tag implementation.
Bump!
Bump!
...
From what I can tell, what you want to do is dangerously close to spamming the search engines, almost like doorway pages but for link juice. The attribute is not for this purpose, so why should any drupal module support it, I certainly don't want that as it could be set accidentally by a client and they could be severly punished.
You are talking about having the same canonical url for two different nodes, which is quite different to having two different URL's for the same node, IMO.
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
What are you talking about?
That has nothing to do with spamming. That was one of the main initiatives behind canonical tag. That should be obvious.
I want same product description under two different categories.
...
Having "A" (one, singular, a unique node) node appear in two different categories is NOT THE SAME AS TWO NODES WITH THE SAME CANONAICAL URL! Which is what YOU asked - you asked how to have TWO NODES WITH THE SAME CANONICAL URL - read your own question - that is what is YOU asked.
FYI its not my problem if you don't know the terminology nor software well enough to forumulate the right question.
/widgets/xyz-widget.html (say this is the canonical URL)
/widgets/blue/xyz-widget.html (widget appears in a category, canonical URL is /widgets/xyz-widget.html)
http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonica...
From the explanations I have read about the patched Global redirect module that is exactly what is does and is the expected behaviour.
/out
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
I said: "I want to create two
I said:
"I want to create two nodes with identical content, redirected by url alias to its own url, but I want to tell search engines which url is canonical to avoid having duplicate content."
That means:
node1 - url alias: /widgets/xyz-widget.html
node2 - url alias: /widgets/blue/xyz-widget.html
/widgets/blue/xyz-widget.html has /widgets/xyz-widget.html set as canonical
We don't have to think in this scenario about url node1 and node2 because they are already permanently redirected to aliases so they aren't visible to visitors and search engines.
That is not possible to accomplish with global redirect because it only can set url alias as canonical, so in this example node1 would have /widgets/xyz-widget.html as canonical and node2 would have /widgets/blue/xyz-widget.html as canonical and then there is duplicate content on those two urls.
...
Which is exactly why you shoud have one node only, and blue is merely a category or view ect, so there is one node, one canonical url, no duplicate content, not problems.
The whole point of canconcial URL's is that you have one url for multiple instances of the same content - such as when displaying the node in a search result, category or View, not to have one canonical URL for many different nodes! That is why this should never, ever be an expected behaviour of any module built with SEO in mind.
Do you understand how Drupal taxonomy or Views works?
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
blue is merely a
blue is example, btw your example.
Please READ that.
If you read that announcement from Google Webmaster Central you'll see that the whole point of canonical url is solving duplicate issues from same OR VERY SIMILAR content on two different urls. Same product description under two categories is the most common case.
They have a lot of functions but cannot replace usage of canonical url, it is the most simple solution for same product description under two categories.
This dialogue between you and me is leading nowhere. You are not trying to help nor understand. I give up.
...
Do you not realise that two nodes have different created times, different updated times, using a sitemap.xml?, its right there for all to see...
I dont expect you to understand the possible implications of that, because you have not understood a single word I have said all the way through this thread.
Bye bye...
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
"The attribute is not for
"The attribute is not for this purpose, so why should any drupal module support it,"
Nodewords 6.x-1.x-dev is doing exactly what it should do and what I need, very simple - it gives form on node editing page where canonical url can be specified.
But it has one failure, if canonical url isn't specified it defaults it to homepage.
subscribe
Great to hear someone other have the same thoughts ...
canonical_url
I digged a little into modified global_redirect module. In fact, it doesn't suit my needs, so I decided to created something dedicated to canonical urls - http://drupal.org/project/canonical_url
http://www.valthebald.net
Maybe, no need in module
You can use drupal_add_link() function in preprocess_page or any existing module hook_init, like this:
drupal_add_link(array('rel' => 'canonical',
'href' => $url));
or, it will take exactly 10 mins to write a module that will do right that :)
http://www.valthebald.net
Proper Convention
I just added this to my page.tpl.php file in the head section. I'm not sure if this is proper convention on how to write the proper code or the place I chose to put it, but it works fine. This pulls the auto-url path that was generated from the title when creating a node. So http://www.example.com/node/1234 becomes http://www.example.com/content/insert-title-here for all canonical urls. This was for Drupal 5. Feel free to give me any advice if this could be improved.
...
There could be more than one url alias. So get the most recent one.