# Backlinks (Section-aware) Plugin for DokuWiki

Add lists of backlinks to a page. Unlike the upstream Backlinks plugin,
each rendered link points to the **section (heading)** the backlink
originates from, not just the top of the source page.

## Usage

The syntax keyword is:

    {{backlinkswas>[pagename][#filterNS][#!filterNS]...}}

- `[pagename]` — a valid wiki pagename, or `.` for the current page.
- `[filterNS]` — a valid absolute namespace, optionally prefixed with `!` to exclude.

Examples:

    {{backlinkswas>.}}
    {{backlinkswas>some:page#docs#!docs:drafts}}

## How it works

1. The plugin asks DokuWiki's metadata index which pages link to the
   target page.
2. For each candidate page it reads the raw wiki source and locates
   every `[[...]]` link that resolves to the target.
3. For each match it determines the nearest preceding heading (unless
   the link itself carries an explicit `#fragment`, in which case that
   is used).
4. The rendered link is `page#section` and the label is
   `Page Title » Section Title`.

## Credits

Original Backlinks plugin:

- **Mark C. Prins** <mprins@users.sf.net>
- **Michael Klier** <chi@chimeric.de>

Section-aware modifications:

- **Wizardry and Steamworks** <wizardry.steamworks@outlook.com> (2026-09-21)

## Licence

GPL 2 — see `COPYING`.

Upstream documentation: <https://dokuwiki.org/plugin:backlinks>
