Repository navigation
Send a canonical Link header for games that name one - #7
Merged
Merged
Conversation
A game reachable at its slug host, an alias and the portal page that frames it was indexed three times. The optional `canonical:` registry key adds `Link: <url>; rel="canonical"` to the game's HTML responses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BZQMN1M5hQKfUpPwDkMjqd
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.
Why
Each arcade game can be reached at up to three addresses: its slug host (
overwinter.play.danielstephenson.dev), an old alias (overwinter.danielstephenson.dev), and the portal page that frames it (danielstephenson.dev/play/overwinter). Only the portal page declares a canonical URL and carries theVideoGamestructured data. Neither arcade host says anything, so search engines see the same game three times and split its ranking across them.What
registry.py: a new optionalcanonical:key holding an https URL. It is validated strictly, so it can't contain spaces, quotes or<>, the characters a header value would otherwise need escaped. Without the key nothing changes.server.py: when the game has a canonical URL, every HTML response for it (slug host and aliases, GET and HEAD) carriesLink: <url>; rel="canonical", the header form of a canonical link that Google and Bing honor. Assets, the API host, 404s and games without the key send no header. The value is reset on every request, the same wayisolateis, so a reused keep-alive connection can't leak one game's header into another response.Rollout
games.yamlin the gateway rejects unknown keys, so thecanonical:entries can only be added after this ships in a release and the gateway is on it. A follow-up gateway PR will add one line per game, pointing athttps://danielstephenson.dev/play/<portal-slug>.python -m pytest: 138 passed.drafted by Claude on behalf of Daniel Stephenson
🤖 Generated with Claude Code
https://claude.ai/code/session_01BZQMN1M5hQKfUpPwDkMjqd