Canonical URL for the page
The canonical URL is the page URL to use in search results. It is set with the rel="canonical" attribute. You can use it if:
- To a domain with or without the "www" prefix.
- With the HTTPS or HTTP protocol.
The robot might consider these pages duplicates. Then only one of the pages will be included in search results (the one the robot considers more informative). To let the robot know which page should be included in search results, add the canonical URL in the source code of the page that shouldn't be in the search. For example, a page can be accessed at two URLs: www.example.com/pages?id==2 and www.example.com/blog.
If the preferred address is /blog, do I need to show this in the HTML code of the /pages page?id=2:
<link rel="canonical" href="http://www.example.com/blog"/>
The robot will interpret the canonical address as a redirect to the new main mirror and group the two site versions. To do this, go to the source code of each old site page and add a link to the same page on the new site with the rel="canonical" attribute. For example, you change the http://example.com URL to https://example.com. On the http://example.com/main/ page, specify:
<link rel="canonical" href="https://example.com/main"/>
If the attribute points to a different page, the robot might consider this a difference in the site structure. In this case, the site can't be moved.
If you change the URL, make sure that the content of the old site and new site matches. For more information, see relocation instructions.
The attribute is ignored if:
- The canonical URL is unavailable to the robot. In this case, it can't be included in the search. Then a non-canonical URL is included in the search instead of the canonical URL, if it is available to the robot.
The canonical URL points to another domain or subdomain.
Several canonical URLs are specified.
- A chain of canonical URLs is specified. For example, for example.ru/1, the canonical URL is example.ru/2. At the same time, example.ru/2 has the canonical URL example.ru/3.