Skip to content

Replace stable, 1.7.0, 1.9.0, master symlinks with HTML redirect stubs#84

Merged
malfet merged 1 commit intopytorch:sitefrom
atalman:add_rest_of_stubs
Apr 30, 2026
Merged

Replace stable, 1.7.0, 1.9.0, master symlinks with HTML redirect stubs#84
malfet merged 1 commit intopytorch:sitefrom
atalman:add_rest_of_stubs

Conversation

@atalman
Copy link
Copy Markdown
Contributor

@atalman atalman commented Apr 29, 2026

Summary

Follow-up to #83. Applies the same symlink-to-stub conversion to the remaining top-level aliases. After this PR no top-level alias under the docs site is a symlink, so actions/upload-pages-artifact (which runs tar --dereference --hard-dereference) no longer expands aliases into duplicate byte copies in the Pages artifact.

What changed

alias canonical stubs written
stable 2.11 2,883
1.7.0 1.7.1 800
1.9.0 1.9.1 1,649
master main 3,470

master/ previously held one real __redirect__.html plus 2,153 symlinks pointing at it. That layout is replaced with proper per-page stubs that point at the matching canonical path under main/, matching the format used for the other aliases.

Also adds scripts/redirect-stubs/SKILL.md documenting when and how to apply the conversion (the script itself, scripts/make_stubs.py, was added in #83).

Stub format

Each stub uses location.replace(url + location.hash + location.search) so anchor deep-links like stable/torch.html#torch.cat survive the redirect. Crawler / no-JS fallbacks:

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

How it was generated

rm stable 1.7.0 1.9.0
rm -rf master
python3 scripts/make_stubs.py --alias stable --canonical 2.11  --mirror-canonical
python3 scripts/make_stubs.py --alias 1.7.0  --canonical 1.7.1 --mirror-canonical
python3 scripts/make_stubs.py --alias 1.9.0  --canonical 1.9.1 --mirror-canonical
python3 scripts/make_stubs.py --alias master --canonical main  --mirror-canonical

Caveat

As in #83, 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/stable/_images/foo.png) will 404. Clickable HTML links are unaffected — they redirect to the canonical version where the assets live.

Test plan

  • Pages preview deploy succeeds; artifact size is smaller than before.
  • pytorch.org/docs/stable/ → redirects to pytorch.org/docs/2.11/.
  • pytorch.org/docs/stable/torch.html#torch.cat → lands on the #torch.cat anchor under 2.11/.
  • pytorch.org/docs/1.7.0/ → redirects under 1.7.1/.
  • pytorch.org/docs/1.9.0/ → redirects under 1.9.1/.
  • pytorch.org/docs/master/torch.html → redirects to pytorch.org/docs/main/torch.html.
  • find stable 1.7.0 1.9.0 master -name '*.html' -size +1k is empty.
  • find stable 1.7.0 1.9.0 master -type l is empty.

Follow-up to pytorch#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.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 29, 2026
@atalman
Copy link
Copy Markdown
Contributor Author

atalman commented Apr 29, 2026

@claude can you review this PR ?

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.

After carefully reading all 3k+ files I conclude that "I'm going slightly mad"

@malfet malfet merged commit 2074629 into pytorch:site Apr 30, 2026
1 check passed
stecasta added a commit to stecasta/docs that referenced this pull request Apr 30, 2026
…l mode

pytorch#84 left aliases (stable/, master/, 1.7.0/, 1.9.0/) without their
non-HTML build artifacts. The script already has

    DEFAULT_KEEP = {"searchindex.js", "objects.inv", ".buildinfo"}

and the default walk-alias mode honors it correctly. The bug:
--mirror-canonical mode iterates iter_canonical_html() (filtered
to .html), so keep-files are never copied.

Net effect: https://pytorch.org/docs/stable/objects.inv now 404s,
breaking intersphinx for every downstream Sphinx/mkdocstrings
project (vllm, lightning, vision, audio, skorch, ...).

This patch makes --mirror-canonical walk the full canonical and
byte-copy keep-listed files. Default walk-alias mode unchanged.

Verified locally: a synthetic canonical with HTML pages plus
objects.inv/searchindex.js/.buildinfo now produces an alias dir
with HTML stubs AND byte-identical copies of the three keep-files.
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