Google maintains a Support Article listing all the different ways you can specify which of your links to treat as the "canonical" or "main" version when google detects that your site has multiple pages that are duplicates (that is if they are in fact actually duplicates, if the pages aren't "meant" to be duplicates, find out why and fix it).
Reasons you may see duplicate URL's:
There are valid reasons why your site might have different URLs that point to the same page, or have duplicate or very similar pages at different URLs. Here are the most common:
To support multiple device types:
https://example.com/news/koala-rampage
https://m.example.com/news/koala-rampage
https://amp.example.com/news/koala-rampage
To enable dynamic URLs for things like search parameters or session IDs:
https://www.example.com/products?category=dresses&color=green
https://example.com/dresses/cocktail?gclid=ABCD
https://www.example.com/dresses/green/greendress.html
If your blog system automatically saves multiple URLs as you position the same post under multiple sections.
https://blog.example.com/dresses/green-dresses-are-awesome/
https://blog.example.com/green-things/green-dresses-are-awesome/
If your server is configured to serve the same content for www/non-www http/https variants:
http://example.com/green-dresses
https://example.com/green-dresses
http://www.example.com/green-dresses
If content you provide on a blog for syndication to other sites is replicated in part or in full on those domains:
https://news.example.com/green-dresses-for-every-day-155672.html (syndicated post)
https://blog.example.com/dresses/green-dresses-are-awesome/3245/
(original post)
I should also add an example for analytics campaigns. In my case, google is detecting url's with third-party (not google) campaign URL parameters as separate (and therefore duplicate) pages.
Telling Google about your Canonical pages:
The support article also includes a table and details on various methods for telling google about canonical pages roughly in importance order:
- add a
<link>
tag to the HTML of all duplicate pages with the rel=canonical
attribute to point to the new URL (i.e. googles example: <link rel="canonical" href="https://example.com/dresses/green-dresses" />
)
- rel=canonical HTTP headers. (i.e.
Link: <http://www.example.com/downloads/white-paper.pdf>; rel="canonical"
)
- Submit your canonical URL's in a sitemap
- Use 301 (permanent) redirects for URLs that have permanently moved so that the old and new locations aren't marked as duplicates of each other