Repository navigation
Republish the course to fix sidebar links going to /docs instead of /learn - #29
RafaelJaime wants to merge 2 commits into
Conversation
Every sidebar (and prev/next) click on huggingface.co/learn/context-course navigates to https://huggingface.co/docs/context-course/main/en/<page> instead of https://huggingface.co/learn/context-course/<page>. The server-rendered HTML is correct — the anchors do point at /learn/... . The rewrite happens client-side, in the doc-builder SvelteKit app that is bundled into the published build: /* _app/immutable/chunks/4N2m5NWB.js, currently live for context-course */ function d(t){if(/^\/(docs|learn)/.test(t)){ ... return `/docs/context-course/main/en/${i}` }} That is the pre-fix `getHfDocFullPath()` from doc-builder's kit. Its caller in kit/src/routes/+layout.svelte momentarily rewrites the clicked anchor's pathname in the DOM so SvelteKit treats it as an internal route. For courses this turns /learn/context-course/unit1/skill-format into /docs/context-course/main/en/unit1/skill-format before the Hub's own link handler reads it, so the Hub requests /api/docs/... (404 — courses are served from /api/learn/) and falls back to a full navigation to the /docs URL. Going back works because back/forward deliberately falls back to a full page load of the shorthand URL, which the server resolves correctly. Upstream already fixed this in huggingface/doc-builder#828 (be7b9d0, 2026-09-24), which stops expanding /learn links. The live context-course build predates it and still ships the broken helper. This repo is the only HF course still calling the reusable workflows with @main, which is how it picked up the regressed kit from doc-builder#792 in the first place. Pin all three workflows to doc-builder 61704e2 (current main, contains the fix), matching what mcp-course, agents-course and smol-course already do. Merging this pushes to main and therefore triggers a rebuild with the fixed kit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`Build documentation` only triggers on push to main, so the course can only be republished by landing a commit. That matters here because the fix for the /learn sidebar links lives in doc-builder, not in this repo: the kit JS is compiled into the published build, so an upstream fix reaches readers only when the course is rebuilt. Add workflow_dispatch so a maintainer can republish from the Actions tab, as huggingface/transformers already does. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Closing in favour of #30. On reflection this repo does not need a diff. The Re-running The (edited: the original comment lost two inline code spans to shell expansion) |
Problem
Every link in the sidebar of https://huggingface.co/learn/context-course navigates to the
/docs/...URL space instead of/learn/...:https://huggingface.co/learn/context-course/unit1/skill-formathttps://huggingface.co/docs/context-course/main/en/unit1/skill-formatThe same happens for the prev/next footer links. Pressing the browser Back button lands on the correct
/learn/...URL, which is a useful clue about where the rewrite happens.Root cause
The server-rendered HTML is correct — the anchors really do point at
/learn/...:The rewrite is done client-side by the
doc-builderSvelteKit app bundled into the published build. This chunk is live forcontext-courseright now:That is the pre-fix
getHfDocFullPath()fromkit/src/lib/hfDocPaths.js. Its caller inkit/src/routes/+layout.sveltemomentarily rewrites the clicked anchor'spathnamein the DOM so SvelteKit's own click handler resolves it as an internal route:const shorthandPathname = anchor.pathname; const fullPath = getHfDocFullPath(shorthandPathname); if (fullPath && fullPath !== shorthandPathname) { pendingShorthand = { href: anchor.href, fullPath }; anchor.pathname = fullPath; // /learn/... -> /docs/.../main/en/... setTimeout(() => { anchor.pathname = shorthandPathname; }); }For a course page the Hub's own link handler then reads the already-rewritten
/docs/...path and requests/api/docs/context-course/main/en/..., which does not exist (courses are served from/api/learn/...), so it falls back to a full navigation to the/docsURL. Back/forward works because it deliberately falls back to a full page load of the shorthand URL, which the server resolves correctly — the caveat is documented in the same component.The client-side rewrite was introduced by huggingface/doc-builder#792 (Svelte 5 / SvelteKit 2 kit upgrade) and already fixed upstream by huggingface/doc-builder#828 (
be7b9d0, 2026-09-24), which stops expanding/learnlinks:The published
context-coursebuild predates that fix and still ships the broken helper, so the bug is visible today.Why this needs a change here and not upstream
doc-builderis already fixed — there is nothing left to patch there. The reason the course is still broken is that a published course is a frozen build artifact: the kit JS is compiled into it, so an upstream fix only reaches readers when the course itself is rebuilt./learn→/docsrewriteBuild documentationrun for this repo (0b4572f), resolving@mainto the regressed kit — course breaksbe7b9d0) fixes it upstreamWhy this repo is affected and the other courses are not
context-courseis the only HF course still calling the reusabledoc-builderworkflows with@main:doc-builderrefmcp-course90b4ee2c…# mainagents-coursebcff59fc…# mainsmol-course90b4ee2c…# maincontext-course@main(floating)Those pins predate #792, so those courses never received the regressed kit.
context-coursefloats onmain, so it picked the regression up on its last build and will keep absorbing whatever lands upstream.Fix
The actual repair is a rebuild, not a diff. Since this repo calls the reusable workflows with
@main, a build started today already resolves to a fixeddoc-builder. The problem is thatBuild documentationonly triggers onpushtomain, so there is no way to republish from the Actions tab — a commit has to land. This PR therefore does three things, in order of importance.1. Republish the course
Merging lands a commit on
main, which triggersBuild documentation, which republishes with the fixed kit. That alone makes the sidebar links resolve to/learn/context-course/...again.2. Make a rebuild possible without a commit (
workflow_dispatch)The fix for this bug lived upstream and still does; the course was broken purely because it had not been rebuilt since. With only a
pushtrigger, "the upstream fix is in, we just need to republish" requires a dummy commit. Addingworkflow_dispatch:turns it into a button, as huggingface/transformers already does. This is the change that makes the next occurrence a one-click fix.3. Pin the reusable workflows
Pin all three workflows to
doc-builder61704e23fa97c0502ce5355c489c6bec4194bff1(currentmain, which containsbe7b9d0), matching the convention the sibling course repos adopted in their "🔒 pin ... actions to commit SHAs" commits.This does two things:
main, which triggersBuild documentation, which republishes the course with the fixed kit — so the sidebar links start resolving to/learn/context-course/...again.@mainis exactly how the regression arrived; it is also why GitHub's hardening guide recommends pinning reusable workflows to a full commit SHA, anddoc-builder's ownbuild_main_documentation.ymlrelies on the caller's pin to decide whichdoc-buildercode runs with the build secrets.This repo already decided to pin, it just never finished the job.
0b4572f("chore: track GitHub Actions versions with Dependabot", 2026-09-18) added.github/dependabot.yml, which opens with:Dependabot is configured for
github-actionsweekly with a 7-day cooldown and grouped PRs — but the threedoc-builderuses:refs were left on@main, which Dependabot cannot raise because there is no version to raise. This PR supplies the SHAs that config was written to maintain, so the pins stay current automatically and the usual objection to pinning ("it freezes you out of upstream fixes") does not apply here.The trailing
# maincomment follows the existing convention in the other course repos so Dependabot / a future bumper can still tell which branch the SHA came from.Alternatives considered
Fix it upstream instead. Not available — huggingface/doc-builder#828 already did, six days after this course's last build. Nothing reaches readers until the course republishes.
Just trigger a rebuild, no diff at all. Correct, and it is the part of this PR that actually repairs the site — re-running the 2026-09-18 run would re-resolve
@mainto a fixeddoc-builderand the symptom would go away. Two reasons it is not the whole answer: there is noworkflow_dispatch, so a maintainer's only options today are "Re-run jobs" on a six-month-old run or a dummy commit; and it leaves the repo floating on@main, which is exactly how the regression arrived on 2026-09-18. If you would rather keep this minimal, drop commit 2 (the pin) and keep commit 1 — the rebuild and the manual trigger are the parts that matter, and the pin can land separately as the Dependabot follow-up it really is.Verification
/learn/...anchors (so this is not a_toctree.ymlissue).getHfDocFullPath(quoted above).git merge-base --is-ancestor be7b9d0 61704e2confirms the pinned SHA contains the upstream fix;kit/src/lib/hfDocPaths.jsat that SHA tests/^\/docs\//only.Build PR Documentationon this PR exercises the two PR workflows with the new pin.🤖 Generated with Claude Code