Backlinks
Series: Documentation
- 1. Introduction
- 2. Getting Started
- 3. Color Schemes
- 4. Directory Structure and Assets
- 5. Feature Images
- 6. Favicon
- 7. Series
- 8. Archive
- 9. Search
- 10. Backlinks
- 11. Related Article
- 12. Rich Content
- 13. Markdown and Hugo
- 14. Customization
- 15. Reference - Configuration
- 16. Reference - Front matter
- 17. Reference - Icons
Yore embeds a backlink system based on jmooring/hugo-module-backlinks to track and display bidirectional links.
Principle
The system utilizes Hugo's render-link hook to capture internal references. It functions by passing the link's destination to the .GetPage method. If Hugo successfully resolves the path to a page, a backlink entry is recorded in the site-wide store.
Backlinks rely on global state. You need to restart the development server to see updated reference.
Setup
Enable the backlinks output format in hugo.yaml:
outputs:
home:
- HTML
- RSS
- backlinks
outputFormats:
backlinks:
mediaType: application/json
baseName: backlinks
isPlainText: true
notAlternative: true
weight: 1
params:
backlinkEnabled: trueLink Resolution
To ensure backlinks are correctly indexed, use paths relative to the current file or the content directory.
For example, with this directory structure:
content/
├── docs/
│ ├── installation
│ │ └── index.md
│ └── usage.md
└── posts/
└── feature-update.mdIn docs/installation/index.md, you can reference the other content using:
[text](../usage.md)[text](/posts/feature-update.md)or[text](../../posts/feature-update.md)
And in docs/usage.md, you can reference the other content using:
[text](./installation/index.md)[text](/posts/feature-update.md)or[text](../posts/feature-update.md)
For a backlink to be detected, the link path must be resolvable by Hugo's GetPage method. If the path returns nil, the reference will not be indexed.
Posts referencing this article
Series: Documentation
- 1. Introduction
- 2. Getting Started
- 3. Color Schemes
- 4. Directory Structure and Assets
- 5. Feature Images
- 6. Favicon
- 7. Series
- 8. Archive
- 9. Search
- 10. Backlinks
- 11. Related Article
- 12. Rich Content
- 13. Markdown and Hugo
- 14. Customization
- 15. Reference - Configuration
- 16. Reference - Front matter
- 17. Reference - Icons