Google’s John Mueller said in a webmaster hangout on YouTue, that Google often uses the URLs that it finds in XML Sitemaps to determine the canonical URLs of web pages.
Don’t confuse Google
If your website contains different signals for the canonical URLs (XML Sitemaps, 301 redirects, the canonical tag, etc. then Google might become confused:
“The other reason we recommend doing that is that we use Sitemap URLs as a part of trying to understand which URL should be the canonical for a piece of content […], the URL that we should show in the search results.
And if the Sitemap file says one URL and it redirects to a different URL then you’re giving us conflicting information. You’re saying ‘this is the one I want to have shown’ in the second file and that URL itself says ‘actually I want you to choose this other URL instead’.
So […] do we trust a Sitemap file do we trust a redirect target? Is there maybe a rel canonical that’s even different? What is the internal linking like? Does that match any one of these or maybe even a third. And all of that makes it a little bit trickier for us to take the canonical to show in the search results.
So for ranking that doesn’t matter so much. It’s not that we would rank these pages differently depending on the canonical that we choose. But maybe you have a strong feeling and say ‘I want everyone to use this nice-looking URL instead of this ugly looking URL’, then that’s something that you should tell us with the sitemap file, with redirects, with internal linking, all of that.”
You can view the video here:
How to do it right
Use the final destination URL in your XML Sitemap file and use the canonical tag to confirm that URL. The website audit tool in SEOprofiler can create an XML Sitemap for your website. The website audit tool also helps you to remove other errors from your web pages: