Given a category based set of entries/products, and a filter system based on tags, how would I accept (one of) the following urls and let one template process them all (not interested in the processing, just want to know how to set up the route):

  • example.com/category/foo -> category page, containing products
  • example.com/category/foo/type/bar -> category page, filtered by relation to tag (group = 'type') with value 'bar'
  • example.com/category/foo/type/bar/country/usa -> category page, filtered by multiple relations (filters)
  • example.com/category/foo/country/usa/type/bar -> category page, filtered by same relations as above

This would be more SEO-friendly than example.com/category/foo?type=bar&country=usa

Anyone done this before?

1 Answer 1


The parameterized paths (as opposed to the queries) implies a certain hierarchy. According to Google's SEO document, you have to anticipate that users will cut a part of the URL off. What happens if they cut out "usa", but "country"?

What you're doing right now is filtering/searching, not creating a hierarchy. So, you're complicating your own routing (making it more likely to fail and thus hurting your SEO even further), and not conveying the information particularly accurately.

If you want the parameterized URLs as opposed to query strings, you'll want to reorganize your URL structure to be hierarchical -- i.e. - products/shirts/tshirts -- and drop off the "parameter names" that you're trying to shoe-horn in.

Also, consider whether that particular page actually needs to be indexed by search engines, and if it needs to be indexed with the query string. Can you simply allow it to be indexed without any filtering? Does it need to be indexed at all? If you don't need to index it, then you can keep the query string for human usability, and tell spiders not to index it at all. If you don't need to index it as filtered and going to the page, without a query string, results in the non-filtered content, then most spiders will do that by default.

For example, look at google.com, before and after a search. Obviously, search result pages don't need to be indexed (nor would you want to, because that would result in a ton of botched indexed), but the main page, itself, probably should be. As a result, they use a query string that includes q=searchstring on their search results page.

  • Thanks for your elaborate answer! It doesn't answer my question, which I would still like to see answered for future reference, but it did convince me to change my strategy :)
    – Paul
    Nov 7, 2016 at 17:04
  • If there's one thing I've learned in my years as a programmer, it's that if you have to jump through a bunch of hoops to do what you want to do (especially if you're working with a framework or CMS), odds are good you're barking up the wrong tree. :)
    – Shauna
    Nov 8, 2016 at 14:51

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.