Skip to content

Replace 1.10 and 1.10.0 symlinks with HTML redirect stubs (trial)#83

Merged
malfet merged 1 commit intopytorch:sitefrom
atalman:test_stubs
Apr 29, 2026
Merged

Replace 1.10 and 1.10.0 symlinks with HTML redirect stubs (trial)#83
malfet merged 1 commit intopytorch:sitefrom
atalman:test_stubs

Conversation

@atalman
Copy link
Copy Markdown
Contributor

@atalman atalman commented Apr 29, 2026

Summary

Trial run for the symlink-to-stub conversion before applying it everywhere.
Scoped to 1.10/ and 1.10.0/ only — both currently -> 1.10.1.

actions/upload-pages-artifact runs tar --dereference --hard-dereference,
so each top-level alias symlink gets expanded into a full byte copy of its
canonical target. For just these two aliases that's ~196 MB of duplicated
bytes in the artifact. After this PR each alias is a directory of ~500-byte
HTML redirect stubs (~1.8 MB total).

If this deploys cleanly and the redirects behave correctly in browsers,
follow-up PRs will apply the same conversion to stable/, 1.7.0/,
1.9.0/, and master/.

What changed

  • 1.10/ and 1.10.0/ are no longer symlinks; each is a directory of
    HTML stubs (1,719 each) that redirect to the matching path under 1.10.1/.
  • Other aliases (stable, 1.7.0, 1.9.0, master/) are untouched
    they remain symlinks for now.
  • scripts/make_stubs.py is added so the same conversion can be applied
    later (and re-run if 1.10.1 ever changes).

Stub format

Each stub uses location.replace(url + location.hash + location.search) so
anchor deep-links like 1.10/torch.html#torch.cat survive the redirect.
Fallbacks for crawlers / no-JS clients:

<!DOCTYPE html>
<meta charset="utf-8">
<title>Redirecting…</title>
<script>location.replace("../1.10.1/index.html" + location.hash + location.search);</script>
<meta http-equiv="refresh" content="0; url=../1.10.1/index.html">
<link rel="canonical" href="../1.10.1/index.html">
<meta name="robots" content="noindex">
<a href="../1.10.1/index.html">Continue to ../1.10.1/index.html</a>

make_stubs.py modes

  • default: walk an existing alias copy (post-build / CI use)
  • --mirror-canonical: walk the canonical and write stubs into alias
    (used here so we don't commit duplicate _static//_images/ bytes)

Caveat

The alias directories contain only .html stubs — no _static/, _images/,
searchindex.js, or objects.inv. External deep-links to alias assets
(e.g. pytorch.org/docs/1.10/_images/foo.png) will 404. Clickable HTML
links are unaffected — they redirect to 1.10.1/ where the assets live.
For 1.10/1.10.0 specifically the risk of external asset deep-links is low
(old versions, mostly superseded by 1.10.1).

Test plan

  • Pages preview deploy succeeds; artifact size is smaller than before.
  • pytorch.org/docs/1.10/ → redirects to pytorch.org/docs/1.10.1/.
  • pytorch.org/docs/1.10.0/index.html → redirects to 1.10.1/index.html.
  • pytorch.org/docs/1.10/torch.html#torch.cat → lands on the
    #torch.cat anchor under 1.10.1/.
  • find 1.10 1.10.0 -name '*.html' -size +1k is empty (every stub <1 KB).
  • find 1.10 1.10.0 -type l is empty (no symlinks left in the alias dirs).
  • Other aliases (stable, 1.7.0, 1.9.0, master/) still resolve
    via their existing symlinks.

Follow-ups (separate PRs)

  • Apply the same conversion to stable/ (canonical: 2.11/).
  • Apply to 1.7.0/ (canonical: 1.7.1/) and 1.9.0/ (canonical: 1.9.1/).
  • Convert the 2,153 master/* file symlinks to real copies of the existing
    master/__redirect__.html.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 29, 2026
@atalman atalman changed the title Replace version-alias symlinks with HTML redirect stubs Replace version-alias symlinks with a JS-based 404 router Apr 29, 2026
@svekars svekars requested a review from malfet April 29, 2026 21:48
@atalman atalman changed the title Replace version-alias symlinks with a JS-based 404 router Replace version-alias symlinks with HTML redirect stubs Apr 29, 2026
Trial run for the symlink-to-stub conversion before applying to the
remaining aliases (stable, 1.7.0, 1.9.0, master/).

actions/upload-pages-artifact runs `tar --dereference --hard-dereference`,
so the source-level symlinks `1.10 -> 1.10.1` and `1.10.0 -> 1.10.1` get
expanded into ~196 MB of duplicate bytes in the Pages artifact. Replacing
each with a directory of small (~500B) HTML stubs that redirect to the
canonical 1.10.1 version drops that to ~1.8 MB on disk and in the artifact.

The stub uses `location.replace(url + location.hash + location.search)` so
anchor deep-links (e.g. `1.10/torch.html#torch.cat`) survive the redirect,
with a `<meta http-equiv="refresh">` noscript fallback, a `<link rel=canonical>`,
and `robots: noindex` so search engines index the canonical version.

scripts/make_stubs.py generates the stubs. Two modes:
  - default: walk an existing alias copy (post-build / CI use)
  - --mirror-canonical: walk the canonical and write stubs into alias
    (used here so we don't commit duplicate _static/_images bytes)

If this lands cleanly and the deployed redirects work, follow-up PRs will
apply the same conversion to stable, 1.7.0, 1.9.0, and master/.
@atalman atalman changed the title Replace version-alias symlinks with HTML redirect stubs Replace 1.10 and 1.10.0 symlinks with HTML redirect stubs (trial) Apr 29, 2026
Copy link
Copy Markdown
Contributor

@malfet malfet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but please commit make_stubs.py to scripts folder

@malfet malfet merged commit a5f60ff into pytorch:site Apr 29, 2026
1 check passed
malfet pushed a commit that referenced this pull request Apr 30, 2026
Follow-up to #83, applying the same symlink-to-stub conversion to the
remaining aliases. With this PR every top-level alias under the docs
site is a directory of small (~500B) HTML stubs instead of a symlink,
so actions/upload-pages-artifact (which runs `tar --dereference
--hard-dereference`) no longer expands aliases into duplicate byte copies.

Aliases converted:
  - stable/   -> 2.11/   (2,883 stubs)
  - 1.7.0/    -> 1.7.1/  (800 stubs)
  - 1.9.0/    -> 1.9.1/  (1,649 stubs)
  - master/   -> main/   (3,470 stubs; replaces the prior symlinks-to-
                          __redirect__.html scheme with per-page stubs)

Each stub uses
`location.replace(url + location.hash + location.search)` so anchor
deep-links like `stable/torch.html#torch.cat` survive the redirect, with
a `<meta http-equiv="refresh">` noscript fallback, `<link rel=canonical>`,
and `robots: noindex` so search engines index the canonical version.

Generated with `scripts/make_stubs.py --mirror-canonical`. Adds the
companion skill doc at `scripts/redirect-stubs/SKILL.md` describing when
and how to apply the conversion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants