Obsidian-style backlinks for Statamic's Bard and Markdown fields. Create wiki-links between entries, track which pages link to each other, and create new pages from missing links.
Learn more about Obsidian backlinks.
- Wiki-link syntax: Use
[[Page Title]]or[[Page Title|Display Text]]in your content - Backlink tracking: Automatically tracks which entries link to each other
- Missing link detection: Visually distinguish links to non-existent pages
- Page creation: Create new entries directly from missing wiki-links
- Dashboard widget: See backlink activity at a glance
- Entry sidebar: View backlinks when editing an entry
- Antlers tag: Display backlinks in your templates
composer require chrisvasey/statamic-backlinksUse double-bracket syntax in your content fields:
Check out [[Getting Started]] for the basics.
You might also like [[Advanced Topics|our advanced guide]].
Use the wiki_links modifier to render wiki-links as HTML:
{{ content | wiki_links }}This transforms:
[[Existing Page]]→<a href="/existing-page" class="wiki-link">Existing Page</a>[[Missing Page]]→<span class="wiki-link-missing" data-title="Missing Page">Missing Page</span>
Use the backlinks tag to show pages that link to the current entry:
{{ backlinks }}
<a href="{{ url }}">{{ title }}</a>
{{ /backlinks }}
{{# Or just get the count #}}
{{ backlinks:count }}
{{# For a specific entry #}}
{{ backlinks from="entry-id-here" }}
{{ title }}
{{ /backlinks }}Add the backlinks widget to your dashboard in config/statamic/cp.php:
'widgets' => [
[
'type' => 'backlinks',
'title' => 'Recent Backlinks',
'limit' => 10,
],
],If you need to rebuild the backlink index (e.g., after importing content):
php please backlinks:rebuildPublish the config file:
php artisan vendor:publish --tag=statamic-backlinks-configreturn [
// Collections to scan for wiki-links
'scan_collections' => ['*'], // or ['pages', 'blog']
// Collections that can be linked to
'linkable_collections' => ['*'],
// Fields to scan for wiki-links
'scan_fields' => ['content', 'body', 'text', '*'],
// Page creation settings
'creation' => [
'collection_strategy' => 'same', // 'same' or 'default'
'default_collection' => 'pages',
'default_blueprint' => null,
'default_published' => false,
],
// Index storage
'storage' => 'file', // 'file' or 'cache'
'storage_path' => storage_path('statamic/backlinks.json'),
// CSS classes for rendered links
'css' => [
'link' => 'wiki-link',
'missing' => 'wiki-link-missing',
],
];The addon includes basic CSS for wiki-links. You can customize the appearance:
.wiki-link {
color: blue;
text-decoration: underline dotted;
}
.wiki-link-missing {
color: red;
text-decoration: underline dashed;
cursor: pointer;
}cd addons/chrisvasey/statamic-backlinks
npm install
npm run buildFor development with hot reloading:
npm run devcd addons/chrisvasey/statamic-backlinks
./vendor/bin/phpunitMIT License