feat(wiki): backlinks — "What links here" for wiki pages #669

Closed
opened 2026-06-21 06:33:08 +00:00 by jmiller · 1 comment
Owner

Summary

Add a "What links here" feature showing all wiki pages that reference the current page, similar to Wikipedia's backlinks tool.

Current State

No backlink tracking exists. Users have no way to discover which pages reference the page they're viewing.

Design

Route

GET /:owner/:repo/wiki/:page?action=_backlinks

Implementation

  • On request, run git grep against the wiki git repo for the current page name across all .md files
  • Match patterns: [[Page Name]], [text](Page-Name), and raw markdown links containing the page path
  • Return a list of pages that contain references to the current page

UI

  • "What links here" link in the wiki page sidebar or header action bar
  • Backlinks page shows: list of linking pages with the line context where the link appears
  • Badge/count next to the backlinks link showing how many pages reference this one

Performance

  • git grep is extremely fast — no index needed
  • For large wikis, results can be cached per-commit (invalidated on wiki push)

Files to Modify

File Change
routers/web/repo/wiki.go New WikiBacklinks() handler
templates/repo/wiki/view.tmpl Add "What links here" link
templates/repo/wiki/backlinks.tmpl New — backlinks results page

Wikipedia Parity

"What links here" is a core Wikipedia tool used by editors to understand page relationships, detect orphaned pages, and maintain link integrity.

## Summary Add a "What links here" feature showing all wiki pages that reference the current page, similar to Wikipedia's backlinks tool. ## Current State No backlink tracking exists. Users have no way to discover which pages reference the page they're viewing. ## Design ### Route ``` GET /:owner/:repo/wiki/:page?action=_backlinks ``` ### Implementation - On request, run `git grep` against the wiki git repo for the current page name across all `.md` files - Match patterns: `[[Page Name]]`, `[text](Page-Name)`, and raw markdown links containing the page path - Return a list of pages that contain references to the current page ### UI - "What links here" link in the wiki page sidebar or header action bar - Backlinks page shows: list of linking pages with the line context where the link appears - Badge/count next to the backlinks link showing how many pages reference this one ### Performance - `git grep` is extremely fast — no index needed - For large wikis, results can be cached per-commit (invalidated on wiki push) ### Files to Modify | File | Change | |------|--------| | `routers/web/repo/wiki.go` | New `WikiBacklinks()` handler | | `templates/repo/wiki/view.tmpl` | Add "What links here" link | | `templates/repo/wiki/backlinks.tmpl` | New — backlinks results page | ## Wikipedia Parity "What links here" is a core Wikipedia tool used by editors to understand page relationships, detect orphaned pages, and maintain link integrity.
jmiller added the feature: wiki label 2026-06-21 06:33:08 +00:00
Author
Owner

Testing Checklist (manual UI)

  • Cross-reference button visible in wiki page header
  • Click shows all pages referencing current page
  • Context line shown for each backlink
  • Pages in subdirectories found correctly
  • Empty state shows when no backlinks exist
## Testing Checklist (manual UI) - [ ] Cross-reference button visible in wiki page header - [ ] Click shows all pages referencing current page - [ ] Context line shown for each backlink - [ ] Pages in subdirectories found correctly - [ ] Empty state shows when no backlinks exist
Sign in to join this conversation.