In Magento 2 you can enable canonical URLs for products and categories. Setting canonical URLs is a way to direct search engines to a single canonical URL for indexing thus avoiding duplicate content.
Magento search for sites running on Magento 2
- Log in to your Magento 2 admin panel.
- click stores->settings-> configuration
- Go to catalog in the left panel.
- Click search engine optimizations
- Set both Use Canonical Link Meta Tag for Categories and Use Canonical Link Meta Tag for Products to yes.
- Click save the config.