3

Should I remove the entire query string from URLs in the canonical meta tag?

For example this URL:

https://example.com/Turkey/Istanbul/Vehicles/Car/Peugeot?b=11&d=2

This b=11 returns a list of all 2008 Peugeots, and d=2 specifies the district.

I see some websites remove the whole query string from URLs and would set the canonical to:

https://example.com/Turkey/Istanbul/Vehicles/Car/Peugeot

But this URL returns a different value than with query strings. So, Which one is right method?

  1. Removing query string from canonical?
  2. Set a self canonical including the query string?
6

Query parameters can be used for many purposes. Some of them don't specify the page content and some of them do. If the query parameter is used to specify the content loaded onto the page, then it should be included in your canonical URL. If the query parameter is used for tracking or changes an insignificant part of the page, then it should be left out of the canonical URL.

You say "this URL returns different value than with query strings". I think by that you mean that the query strings change the content. So you should include those query parameters in your canonical URL.

Because you are using two parameters you have an ordering issue. URLs with ?b=11&d=2 and URLs with ?d=2&b=11 would return the same content. Your canonical URL should be very strict about the parameter order that you prefer. With multiple query string parameters that change the content, it is a very good idea to use canonical tags to avoid duplicate URLs getting indexed.

Many sites like to avoid parameters that effect SEO. It is a common practice to rewrite URLs like yours to one of:

  • /Turkey/Istanbul/Vehicles/Car/Peugeot/11/2
  • /Turkey/Istanbul/Vehicles/Car/Peugeot/2018/District-2

Doing so avoids ordering issues and makes it clear which portions of the URL are important for SEO. The second of those two URLs uses words that are meaningful to users which can help usability.

Adding tracking parameters will change the URL, but shouldn't change the page. For example ?b=11&d=2&utm_source=ad might be a URL that returns the same content but which has a tracking parameter related to the advertising for your site. The tracking parameter should be omitted from your canonical URL while the parameters that change the content of the page should be included.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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