Canonical link injection - #157
Merged
Merged
Conversation
Every post-transform-for-static-hosting index.html stub currently carries no page-identifying metadata, so versioned rebuilds of the same content (main, release branches, etc.) have nothing telling search engines which copy is authoritative. Adds an opt-in build_docs.py step, gated by a new --canonical-base-url flag, that stamps a self-describing <link rel="canonical"> into every route's stub, all pointed at the same fixed base URL regardless of which version_slug produced the archive. Addresses swiftlang#135.
Replaces the --canonical-base-url CLI flag with an optional top-level canonical_base_url field in sources.json, alongside version. Canonical injection is a property of the single combined archive a build produces, not of any one source, so it belongs with the other whole-build config rather than being passed per-invocation. Sets it to https://docs.swift.org/latest on main, per the policy that every version_slug build should declare the same canonical target.
Member
Author
|
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.
Summary
This PR adds an overlay that injects HTML canonical links (
<link rel="canonical" href="...">into the HTML pages for the combined docs, relative to the page they're presenting.This should avoid de-listing with having duplicates of the content available (and scrape-able), and provide the canonical location for any agents or crawlers that read the provided content.
resolves #135 for the short term - doesn't handle support upstream in DocC processing and tooling, but coded so that IF/WHEN that happens, the processing will be redundant and non-destructive.
Validation
<head>By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.