大网数据广告活动
网站运营与故障问答

Should query strings be included or removed from the canonical tag?

· 52CE 我爱测

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…

问题原文

原帖链接 · Pedram · CC BY-SA 3.0

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?

已采纳解答

原帖链接 · Stephen Ostermiller · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2018-04-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。