Add canonical URL support for posts that also live on posit.co/blog - #367
Open
gregswinehart wants to merge 1 commit into
Open
Add canonical URL support for posts that also live on posit.co/blog#367gregswinehart wants to merge 1 commit into
gregswinehart wants to merge 1 commit into
Conversation
Every page now emits a self-referencing <link rel="canonical"> tag by default. Posts whose canonical version lives elsewhere (e.g. the same post on posit.co/blog) can set canonical_url in frontmatter to point the canonical tag and blog JSON-LD there instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
✅ Deploy Preview for posit-open-source canceled.
|
Contributor
Publishing checklist
|
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Some of our blog posts are published in two places: here on the open source site and on posit.co/blog. When the same article exists at two URLs, search engines like Google have to guess which one is the "real" version — and they may split ranking credit between the two copies, or show the wrong one in search results.
The fix is a standard web mechanism called a canonical URL: an invisible tag in the page's code that tells search engines "this is the official home of this content — send all the search credit there." Readers never see it; only search engine crawlers do.
How it works now
By default, every page on this site declares itself as the official version. No action needed from post authors — this happens automatically.
When posit.co's copy should be the official version, the post author adds one line to the post's metadata:
The page then tells search engines to treat the posit.co version as the real one, and our copy stops competing with it in search results. The post itself still displays normally on our site for anyone who visits.
What changed technically
layouts/partials/head.html— every page now emits a<link rel="canonical">tag (self-referencing by default, or pointing atcanonical_urlwhen set). The site previously emitted no canonical tags at all.layouts/partials/jsonld.html— the structured data we provide to search engines for blog posts now uses the same canonical URL, so both signals agree.content/blog/CLAUDE.md— the new field is documented in the blog metadata reference.One limitation to know about
This only covers the case where posit.co's copy is the official one. For the reverse — where our copy should be official — the tag has to be added on posit.co's side, which is outside this repo. That needs coordination with whoever manages posit.co.
How it was tested
Ran a full production build: a post with
canonical_urlset correctly pointed its canonical tag and structured data at the posit.co URL, and posts without it correctly pointed at themselves.🤖 Generated with Claude Code
What post goes where?
Most of the historical posts @cwickham brought over to the open source blog are strictly open source themed. Claude found a couple that should probably point to posit.co as the canonical link: