Give each article one canonical URL without pointing every post at the homepage
A shared layout accidentally emits the homepage as the canonical URL for every article. The article's title and content are distinct, but its canonical signal points elsewhere. Generate the canonical from the current public resource, using the configured production origin.
Render a resource-specific canonical
<link rel="canonical" href="https://example.com/writing/database-locks">
The example uses a fictional article URL. The live value should be absolute, stable, and consistent with internal links and the sitemap. Do not derive the trusted origin directly from an arbitrary request Host header.
Keep publication and discovery aligned
A draft should not appear in the sitemap merely because it has a database ID. Use the same publication boundary for detail routes, listings, and sitemap entries. Tracking parameters generally should not create a new canonical article identity.
Canonicalization is a signal for duplicate URL handling, not a ranking guarantee or a substitute for useful content. A unique title, description, and readable article still matter for explaining the page's purpose to people and systems.
Inspect the rendered head of several different articles, not only a layout unit test. Confirm the canonical changes with the article, points to a successful public page, and uses HTTPS on production. If you change URL structure, handle old URLs through an intentional redirect strategy rather than leaving two unrelated public addresses competing for the same article.