Add canonical link injection to public CV pages#164
Merged
Conversation
Crawlers were free to index the same CV under multiple URL variants (http vs https, alternate hostnames behind a reverse proxy, query-string permutations). The public root, the live-CV fallback, and indexable /v/:slug pages now emit a canonical link derived from the request, honoring X-Forwarded-Proto / X-Forwarded-Host the same way sitemap.xml and robots.txt already do — so no extra config is required. Slug pages that resolve to noindex intentionally omit the tag. https://claude.ai/code/session_01EGykcv9Yvem218n13TqYhz
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.
Description
Adds
<link rel="canonical">tag injection to public CV pages to prevent search engine indexing of duplicate content across URL variants. The canonical link is derived from the request and respects reverse-proxy headers (X-Forwarded-ProtoandX-Forwarded-Host), consistent with how/sitemap.xmland/robots.txtare already handled.Behavior:
/) and live-CV fallback pages always emit a canonical link/v/:slugpages emit a canonical link only whenslugsIndexsetting is enabledslugsIndexis disabled,/v/:slugpages receivenoindex, nofollowrobots meta tag insteadImplementation:
buildCanonicalTag(req)helper function insrc/server.jsthat constructs the canonical URL from request headers and pathservePublicIndex()andserveDatasetPage()req.path)Type of Change
Checklist
Required for all code changes
npm testpasses)package.json,package-lock.json,version.json)CHANGELOG.mdhas been updated with a new entry under the correct versionIf adding or changing user-visible strings
Test Coverage
Added comprehensive test suite covering:
X-Forwarded-HostX-Forwarded-ProtoandX-Forwarded-Host)/v/:slugwhenslugsIndexis disabled (withnoindexverification)/v/:slugwhenslugsIndexis enabledAll tests pass with
npm test.https://claude.ai/code/session_01EGykcv9Yvem218n13TqYhz