Skip to content

Links (<a> & <link>) targetting at different version of the current document #12119

@tats-u

Description

@tats-u

What problem are you trying to solve?

Documentation sites that maintain multiple versions face a critical problem:
search engines cannot distinguish between current and outdated versions,
leading to poor search results and user experience.

Concrete example:
Searching "Java regex" on Google (as of February 2026) returns Java 8
documentation as the top result, while Java 25 (current LTS) doesn't appear
on the first page. Users are systematically directed to 17-year-old
deprecated content instead of current documentation.

The problem is worse than it appears:

Even when users realize they're on an outdated version, they cannot easily
navigate to the current version because URL structures differ between versions:

  • Java 8: docs.oracle.com/javase/jp/8/docs/api/java/util/regex/package-summary.html
  • Java 25: docs.oracle.com/javase/jp/25/docs/api/java.base/java/util/regex/package-summary.html

Simply replacing "8" with "25" in the URL fails due to structural changes
(java.base module addition). Each documentation site has its own URL
conventions, requiring site-specific knowledge to navigate between versions.

Root cause:
There is no standardized, machine-readable way for sites to declare:

  • "This page documents version X"
  • "The equivalent page in version Y is at URL Z"
  • "Version Y is the current/recommended version"

Why existing solutions fail:

  1. URL conventions are site-specific: While Python uses /3/ for current
    docs and /3.<version number>/ for specific versions, most projects use different schemes
    (domain-based, path-based with structural changes, etc.). No universal
    pattern exists.

  2. rel="canonical" is inappropriate: It's for duplicate content, not
    version relationships. Marking v8 as canonical to v25 would hide v8
    entirely, but users sometimes legitimately need older versions.

  3. Version selectors are opaque to crawlers: Current implementations use
    <select>, <ul>, or JavaScript widgets. Crawlers cannot understand
    "this link leads to the v25 equivalent of the current page" vs "this is
    just a link to v25's homepage."

  4. No way to signal "current/recommended": Sites cannot tell search
    engines "prefer v25 over v8 when ranking for generic queries."

Impact:

  • Developers waste time with deprecated APIs and outdated best practices
  • Documentation maintainers cannot control which version appears in search results
  • Outdated content perpetually ranks higher due to accumulated backlinks and age
  • Users must learn site-specific URL patterns to navigate between versions
  • This primarily affects software documentation (libraries, frameworks,
    languages, APIs) but could apply to any versioned content

What solutions exist today?

Use the title attribute in <a> or <link> tag:

<ul id="version-selector">
  <li>3.x</li>
  <li><a rel="alternate" title="2.x" href="://v2.example.com/">2.x</a></li>
  <li><a rel="alternate" title="1.x" href="://v1.example.com/">1.x</a></li>
</ul>

However, it is difficult for crawlers to understand that the links are the variants for different versions.

How would you solve it?

Add hrefversion attribute to <a> and <link> elements to explicitly
declare cross-version relationships:

<ul id="version-selector">
  <li>3.x</li>
  <li><a rel="alternate" hrefversion="2.x" href="://v2.example.com/">2.x</a></li>
  <li><a rel="alternate" hrefversion="1.x" href="://v1.example.com/">1.x</a></li>
</ul>
<div class="banner">
  This version of the document is outdated. <a rel="alternate" hrefversion="latest" href="/foo/bar">See the latest version.</a>
</div>
<link rel="alternate" hrefversion="2.x" href="://v2.example.com/">
<link rel="alternate" hrefversion="1.x" href="://v1.example.com/">

Benefits:

  1. Search engines can identify version relationships even when URL
    structures differ completely between versions

  2. Search engines can prefer the latest versions in generic queries while
    still indexing older versions for specific searches

  3. Browsers could offer version-switching UI (e.g., "A newer version of
    this page is available")

  4. Crawlers can discover all versions from any entry point, improving
    documentation coverage

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    addition/proposalNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interest

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions