fix(redirects): honor legacy go.php doc links on the static site - #5137
Merged
Conversation
ownCloud core builds documentation deep links via OC_Defaults::buildDocLinkToKey() as https://doc.owncloud.com/server/<version>/go.php?to=<key>. On the old Sphinx site go.php was a server-side PHP script that 302-redirected each key to the real page. The docs now build as a static Antora site on GitHub Pages, which runs no PHP and ignores the query string, so every go.php?to= URL 404s. Every already-deployed server keeps emitting these links, so the fix must live on the site. Add a client-side redirector shipped as Antora supplemental files layered on the remote docs-ui bundle: - supplemental/js/go-redirect.js: maps each go.php key to its page under the version root, remaps unpublished version segments (e.g. the concrete 10.16 current stable, or old releases) to /server/latest/, and falls back to the version-root entrypoint for unknown/missing keys. Runs in <head> and is a no-op unless the path ends in go.php, so it redirects before the 404 body paints. - supplemental/partials/head-scripts.hbs: overrides the bundle partial to load the redirector. Reproduces the bundle's Matomo block and the uiRootPath global (overriding the partial wholesale would otherwise drop them). - site.yml: enable the supplemental overlay (supplemental_files). - test/go-redirect.test.js + npm test + CI step: unit-test the mapping logic and guard against version drift and page moves by asserting, on the built site, that PUBLISHED_VERSIONS matches public/server/* and every mapped target exists under public/server/latest. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
phil-davis
approved these changes
Jul 24, 2026
Contributor
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.
What
ownCloud core builds documentation deep links via
OC_Defaults::buildDocLinkToKey()ashttps://doc.owncloud.com/server/<version>/go.php?to=<key>. On the old Sphinx sitego.phpwas a server-side PHP script that 302-redirected each key to the real page. The docs now build as a static Antora site on GitHub Pages, which runs no PHP and ignores the query string, so everygo.php?to=URL 404s. Every already-deployed ownCloud server keeps emitting these links, so the fix must live on the site.This ports
owncloud-docs-monorepoPR #35 to the productionowncloud/docsplaybook. It ships a client-side redirector as Antora supplemental files layered on the remotedocs-uibundle — nothing inowncloud/docs-uichanges.How
supplemental/js/go-redirect.js— maps eachgo.phpkey to its page under the version root, remaps unpublished version segments (the concrete current stable like10.16, or old releases) to/server/latest/, and falls back to the version-root entrypoint for unknown/missing keys. It runs in<head>on every page and is a no-op unless the path ends ingo.php, so it redirects before the 404 body paints (no visible flash).supplemental/partials/head-scripts.hbs— overrides the bundle partial to load the redirector. Overriding a stock partial wholesale drops its contents, so this reproduces the bundle's Matomo block and theuiRootPathglobal, then adds the redirector<script>.site.yml— enables the supplemental overlay (supplemental_files: supplemental).test/go-redirect.test.js+npm test+ CI step — unit-tests the mapping logic and, on the built site, guards against version drift (PUBLISHED_VERSIONSmust equalpublic/server/*) and page moves (every mapped target must exist underpublic/server/latest).Adaptations from PR #35
/server/latest/…), not the monorepo's repo path prefix — the redirector logic is prefix-agnostic and needed no change.PUBLISHED_VERSIONS = ['10.15', 'next', 'latest']— the segments this playbook actually emits (10.16is served at/server/latest/vialatest_version_segment_strategy: replace;masterat/server/next/).node --testwired into CI after the build step so the guards run againstpublic/.Testing
npm test— 15 tests pass (the two build-dependent guardst.skipwhenpublic/is absent).npm run antora && npm test— full build; guards confirmpublic/server/*=10.15,latest,nextand every mapped target exists underpublic/server/latest./server/latest/go.php?to=admin-sharing→…/admin_manual/configuration/files/file_sharing_configuration.html; unknown key →…/index.html;/server/10.16/go.php?to=user-webdav→/server/latest/classic_ui/files/access_webdav.html.Out of scope
owncloud/corebuildDocLinkToKey()change (Part B).owncloud/docs-ui.🤖 Generated with Claude Code