I use the Tags taxonomy on several of my content types. In order to assist with a site-wide filtering mechanism, I'd like to be able to create additional path aliases for each piece of content.

For example, if my tags include baseball, football, soccer, and I post a news Article, I would like to have a primary path alias to that node using:


but I'd also like to create a path alias to it for:




However, when I create these programmatically, drupal seems to choose one of them, arbitrarily, to be the canonical alias. Is there any way I can control which alias is the canonical one?

  • Unfortunately there's no concept of a canonical URL per se in Drupal core. If there are multiple aliases for a path you'll just get the last one by its id (pid column in the DEB) when you execute url() or related functions. So the scenario you propose is problematic as it's hard to guarantee which alias is the last one by id. Why have the extra aliases? Generally multiple URLs for the same content is not regarded as a good idea. Jun 4, 2013 at 8:37
  • Well, it's only considered a bad idea because it can hurt pagerank but with the canonical header tag, then Google doesn't penalize you. The problem I'm trying to solve has to do with a client request where they want to do site-wide term-based content filtering. I can do that for all of my views pages, but when a user browses to a specific node I need a way to maintain that filtering when they click on more links from the node. So, I just want to let each node be addressed via every filter and that makes it easy to persist the filtering term. Jun 4, 2013 at 20:50
  • Your last comment pretty much changes meaning of your question. Consider asking it as a new question as it seems interesting. Now answer by @AlfredArmstrong is almost off-topic in context of question as written - and bad, it's an interesting approach, it just address your comment, not question.
    – Mołot
    Jun 5, 2013 at 13:02
  • Sorry about that - just trying to be helpful :) Jun 5, 2013 at 13:40
  • @AlfredArmstrong I know, I haven't flagged it or anything. I was just suggesting it deserves separate Q&A entry... and that it's actually OP's responsibility to initiate it.
    – Mołot
    Jun 5, 2013 at 14:25

4 Answers 4


Metatg seems to be your answer:

Currently supported meta tags:

  • Abstract

  • Author

  • Canonical URL

  • Copyright

  • Description

  • Dublin Core (sub-module)

  • Generator

  • Image source

  • Keywords

  • News Keywords

  • Open Graph Protocol (sub-module)

  • Original Source

  • Publisher URL

  • Robots

  • Shortlink URL

  • Title (e.g. Page titles)

  • Twitter Cards (sub-module)


Mołot's answer does offer a way to set which url is canonical, so I've accepted it.

I also found a workaround which is simply to create my canonical path alias last. Whichever path alias has the highest path id appears to be the one chosen as the canonical path.


Could you use the Redirect module to redirect the non-canonical aliases?

This would give you pages that were available under your non-canonical aliases, albeit by a redirect.


From what you say in the comments, here's an alternative proposal: create a view which takes the arguments as contextual filters and have it display just the one node in full mode. That way you don't have to deal with multiple aliases and you can use the path arguments cleanly.

  • That's different than the problem I'm trying to solve at the moment. I am using Views as you suggest on all of the pages which I list available content and I'm using contextual filters. My problem has to do with addressing an individual node and what url to use. I want to be able to address an node by tag1/content/node-name and tag2/content/node-name so that my filter remains part of the url, but I want that node to still report a single canonical url. Jun 6, 2013 at 0:12
  • What I am proposing that you create a view which simply displays a single node. The variant parts of the URL you mention will again be contextual filters (although they won't actually act to filter the content because the node will possess those values). When a user clicks on a node in the list view they don't go to node/nnnn, they go to a page generated by the new single node view instead. Jun 6, 2013 at 13:54
  • I haven't been able to find a way to add additional contextual filters. The View variant is only seeing the url as node/nnnn even though the url in the browser baseball/news/my-article-1 Jun 6, 2013 at 22:24
  • It sounds like you haven't quite got things set up the way I was trying to suggest. In my solution you wouldn't have the node path aliases any more, instead those would be paths handled by the single node page view. What you are seeing is the underlying problem I was trying to get round - that an alias isn't visible to code inside modules - as far as that code is concerned the path of a node is always node/nnn and it doesn't matter what aliases there might be. Jun 8, 2013 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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