Setting the Canonical URL
Once you decide to start using a canonical tag to uniquely identify your web pages, you need to figure out the best way to set the canonical tag for each page. It is usually best to set the canonical tag to the most simple and concise URL. Since each URL takes you to the same page, all you need to do is to place the canonical tag that is set to the best URL inside the head tag of your web page. Regardless of the URL, the same canonical URL tag will be displayed, which will tell the search engine that that canonical URL is the best URL.
Canonical Tag Example
In this example, we want to set every URL that points to the same content that is on https://www.josepi.com to have a canonical tag set to the URL "https://www.josepi.com".
<link rel="canonical" href="https://www.josepi.com" />
Setting canonical tags provides an excellent way to prevent duplicate content penalties, but it must be used properly. Sometimes, URLs might display the same page but in a slightly different manner. For example, you might have URL parameters that serve as facets that change the order of the page's contents. In this situation, it is probably still the best to use one unique URL in your canonical tag for all of those URLs. Simply because the text is rearranged on the page is not usually a sufficient reason to use different canonical tags for each URL.
Search engines do attempt to solve this multiple URLs pointing to the same content problem. However, search engines might see this as a website attempting to be deceptive just to create more "pages" with different URLs. The deceptive idea is that if you have more web pages regardless of the duplicate content, the more likely your website is to be found in the search results. Of course, this is a terrible idea, and eventually, search engines will discover this behavior and penalize the website resulting in lower search engine result placement than if they had only created one page with one URL. Thus, it is better for you to set the canonical tag before the search engines decide that your website is trying to be deceptive.