feat(wiki): page rename/move with automatic redirects #672

Closed
opened 2026-06-21 13:40:40 +00:00 by jmiller · 1 comment
Owner

Summary

When a wiki page is renamed or moved to a different folder, automatically leave a redirect at the old location so existing links don't break. Similar to Wikipedia's page move system.

Current State

  • EditWikiPost() in routers/web/repo/wiki.go handles renames by calling wiki_service.EditWikiPage(oldName, newName, ...)
  • The old page is deleted and a new one created — no redirect is left behind
  • Any links to the old page name become broken

Design

Redirect File

When a page is renamed, leave a file at the old path containing frontmatter:

---
redirect: new/page/name
---
This page has moved to [[new/page/name]].

Redirect Handling

  • In renderViewPage(), check for redirect key in YAML frontmatter before rendering
  • If found, issue an HTTP redirect to the new page with a flash message: "Redirected from Old Page Name"
  • Show a small notice on the target page: "(redirected from Old Page Name)" with a link to edit/delete the redirect

Double Redirect Resolution

  • When page A redirects to B, and B is later renamed to C, automatically update A to point to C
  • Run as a background check on wiki push events, or as a manual "fix double redirects" action

UI

  • On the rename form, checkbox: "Leave a redirect behind" (checked by default)
  • Special page ?action=_redirects listing all redirect pages in the wiki
  • Ability to delete redirect pages from the redirects list

Files to Modify

File Change
routers/web/repo/wiki.go Redirect detection in renderViewPage(), redirect creation in EditWikiPost()
services/wiki/wiki.go EditWikiPage() — create redirect file at old path
templates/repo/wiki/view.tmpl "Redirected from" notice

Wikipedia Parity

Wikipedia automatically creates redirects on page moves, preserving link integrity across millions of cross-references. This is essential for any wiki with evolving page structure.

## Summary When a wiki page is renamed or moved to a different folder, automatically leave a redirect at the old location so existing links don't break. Similar to Wikipedia's page move system. ## Current State - `EditWikiPost()` in `routers/web/repo/wiki.go` handles renames by calling `wiki_service.EditWikiPage(oldName, newName, ...)` - The old page is deleted and a new one created — no redirect is left behind - Any links to the old page name become broken ## Design ### Redirect File When a page is renamed, leave a file at the old path containing frontmatter: ```markdown --- redirect: new/page/name --- This page has moved to [[new/page/name]]. ``` ### Redirect Handling - In `renderViewPage()`, check for `redirect` key in YAML frontmatter before rendering - If found, issue an HTTP redirect to the new page with a flash message: "Redirected from Old Page Name" - Show a small notice on the target page: "(redirected from Old Page Name)" with a link to edit/delete the redirect ### Double Redirect Resolution - When page A redirects to B, and B is later renamed to C, automatically update A to point to C - Run as a background check on wiki push events, or as a manual "fix double redirects" action ### UI - On the rename form, checkbox: "Leave a redirect behind" (checked by default) - Special page `?action=_redirects` listing all redirect pages in the wiki - Ability to delete redirect pages from the redirects list ### Files to Modify | File | Change | |------|--------| | `routers/web/repo/wiki.go` | Redirect detection in `renderViewPage()`, redirect creation in `EditWikiPost()` | | `services/wiki/wiki.go` | `EditWikiPage()` — create redirect file at old path | | `templates/repo/wiki/view.tmpl` | "Redirected from" notice | ## Wikipedia Parity Wikipedia automatically creates redirects on page moves, preserving link integrity across millions of cross-references. This is essential for any wiki with evolving page structure.
jmiller added the feature: wiki label 2026-06-21 13:40:40 +00:00
Author
Owner

Testing Checklist (manual UI)

  • Rename a wiki page → old URL redirects to new page
  • Flash message "Redirected from OldPage" shown
  • Redirect file at old path contains redirect: frontmatter
  • Redirect file is editable/deletable through wiki UI
## Testing Checklist (manual UI) - [ ] Rename a wiki page → old URL redirects to new page - [ ] Flash message "Redirected from OldPage" shown - [ ] Redirect file at old path contains `redirect:` frontmatter - [ ] Redirect file is editable/deletable through wiki UI
Sign in to join this conversation.