Hacker News new | ask | show | jobs
by Asking4AFriend 2793 days ago
> you should always explicitly set the canonical URL for each page.

Could someone explain or give a reliable article that explains this well?

1 comments

When Google crawls your site, it doesn't know the difference between two urls with the same path, but with different GET params.

Theres no way for them to know whether or not the extra params on the URL change the result page. (i.e. example.com/index.php?post_id=1 and example.com/index.php?comment_id=1 could be very different pages, or they could be the same; you don't know).

So in comes the canonical url! This tells Google the proper url required for a specific page. That way if Google gets to a page using two different urls, it can tell that they are the same page.

You can list it by adding a tag to your HTML head.

You can even do face things like rewrite urls entirely (i.e. If the crawler hits example.com/?category_id=1&item_id=2, you can correct the ugly url by listing the canonical url as example.com/category/1/item/2)

https://support.google.com/webmasters/answer/139066?hl=en