Skip to content

Canonical link injection - #157

Merged
heckj merged 4 commits into
swiftlang:mainfrom
heckj:canonical-link-injection
Sep 1, 2026
Merged

Canonical link injection#157
heckj merged 4 commits into
swiftlang:mainfrom
heckj:canonical-link-injection

Conversation

@heckj

@heckj heckj commented Aug 28, 2026

Copy link
Copy Markdown
Member

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

  • build script unit tests all pass, coverage increased
  • full run of the build content, verifying externally that all HTML content includes a canonical ref link in the <head>

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

heckj added 4 commits August 28, 2026 12:48
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.
@heckj heckj self-assigned this Aug 28, 2026
@heckj

heckj commented Aug 28, 2026

Copy link
Copy Markdown
Member Author
  • Canonical link injection scanned 23,723 files and modified 23,723 — full coverage.
  • Verified programmatically: every one of the 23,723 index.html stubs has exactly one tag

@heckj heckj added the enhancement New feature or request label Aug 28, 2026
@heckj
heckj merged commit 76519d6 into swiftlang:main Sep 1, 2026
13 checks passed
@heckj
heckj deleted the canonical-link-injection branch September 1, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

coordinate canonical designation for Swift.org docs content prior to versioned replicas

1 participant