Replace 1.10 and 1.10.0 symlinks with HTML redirect stubs (trial)#83
Merged
malfet merged 1 commit intopytorch:sitefrom Apr 29, 2026
Merged
Replace 1.10 and 1.10.0 symlinks with HTML redirect stubs (trial)#83malfet merged 1 commit intopytorch:sitefrom
malfet merged 1 commit intopytorch:sitefrom
Conversation
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/.
malfet
approved these changes
Apr 29, 2026
Contributor
malfet
left a comment
There was a problem hiding this comment.
LGTM, but please commit make_stubs.py to scripts folder
8 tasks
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.
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
Trial run for the symlink-to-stub conversion before applying it everywhere.
Scoped to
1.10/and1.10.0/only — both currently-> 1.10.1.actions/upload-pages-artifactrunstar --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/, andmaster/.What changed
1.10/and1.10.0/are no longer symlinks; each is a directory ofHTML stubs (1,719 each) that redirect to the matching path under
1.10.1/.stable,1.7.0,1.9.0,master/) are untouched —they remain symlinks for now.
scripts/make_stubs.pyis added so the same conversion can be appliedlater (and re-run if
1.10.1ever changes).Stub format
Each stub uses
location.replace(url + location.hash + location.search)soanchor deep-links like
1.10/torch.html#torch.catsurvive the redirect.Fallbacks for crawlers / no-JS clients:
make_stubs.pymodes--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
.htmlstubs — no_static/,_images/,searchindex.js, orobjects.inv. External deep-links to alias assets(e.g.
pytorch.org/docs/1.10/_images/foo.png) will 404. Clickable HTMLlinks 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
pytorch.org/docs/1.10/→ redirects topytorch.org/docs/1.10.1/.pytorch.org/docs/1.10.0/index.html→ redirects to1.10.1/index.html.pytorch.org/docs/1.10/torch.html#torch.cat→ lands on the#torch.catanchor under1.10.1/.find 1.10 1.10.0 -name '*.html' -size +1kis empty (every stub <1 KB).find 1.10 1.10.0 -type lis empty (no symlinks left in the alias dirs).stable,1.7.0,1.9.0,master/) still resolvevia their existing symlinks.
Follow-ups (separate PRs)
stable/(canonical:2.11/).1.7.0/(canonical:1.7.1/) and1.9.0/(canonical:1.9.1/).master/*file symlinks to real copies of the existingmaster/__redirect__.html.