A canonical URL is the preferred version of a webpage chosen by search engines like Google when there are duplicates. It is an HTML element that helps webmasters prevent duplicate content issues in search engine optimization by specifying the "canonical" or "preferred" version of a web page. Canonical URLs are essential in SEO because search engines like Google don’t want to serve repeat search results or waste resources on pages that offer no unique value. When Google finds duplicate or near-identical pages on a website, it selects a canonical URL to represent all of them and prioritizes this page during indexing and ranking.
The canonical link element can be either used in the semantic HTML <head> or sent with the HTTP header of a document. For non-HTML documents, the HTTP header is an alternate way to set a canonical URL. By the HTML 5 standard, the <link rel="canonical" href="http://example.com/"> HTML element must be used.
In summary, a canonical URL is a way to tell search engines which version of a page is the preferred one when there are duplicates, and it helps prevent duplicate content issues in search engine optimization.