Web development
Declare a canonical URL consistently
A canonical link identifies the preferred URL for a page or a set of substantially duplicate pages. Use a consistent absolute URL that matches your internal links and sitemap.
Worked example
HTML example · save as example.html and open in a browser
<head>
<title>Reading JSON files</title>
<link rel="canonical" href="https://example.com/articles/reading-json/">
</head>How it works
The link expresses a consolidation preference to search engines. On a self-canonical article, it points to the preferred public address of that same content. Consistent trailing-slash, protocol, and hostname choices reduce conflicting signals across navigation and metadata.
Limits and mistakes
Canonicalization is a signal, not a guaranteed directive. Do not point every article at the homepage or use it to hide genuinely different pages. Redirects, sitemap entries, and internal links should support the same preferred address.
Check the result
View the rendered HTML and confirm exactly one intended canonical URL is present. Request that URL and ensure it serves the matching article rather than a redirect chain or error.
Sources
Reference documentation for the behavior used in this guide: