Skip to main content

Related Article

Published:

Series: Documentation

  1. 1. Introduction
  2. 2. Getting Started
  3. 3. Color Schemes
  4. 4. Directory Structure and Assets
  5. 5. Feature Images
  6. 6. Favicon
  7. 7. Series
  8. 8. Archive
  9. 9. Search
  10. 10. Backlinks
  11. 11. Related Article
  12. 12. Rich Content
  13. 13. Markdown and Hugo
  14. 14. Customization
  15. 15. Reference - Configuration
  16. 16. Reference - Front matter
  17. 17. Reference - Icons

Hugo provides a built-in related article feature powered by an inverted index algorithm. This mechanism offers high performance, though its reliance on exact string matching requires specific taxonomy strategies to achieve optimal results.

Principle

The system operates by indexing taxonomies (tags) and dates. It calculates similarity scores based on term overlap between the current page and other pages in the site.

The core logic follows a two-stage process1:

  1. Pre-processing: The engine extracts terms from all pages, maps them to their respective documents, and filters out high-frequency terms based on the cardinalityThreshold.
  2. Calculation: It retrieves terms from the current page, looks up matching documents in the index, and applies weight-based scoring. Pages falling below the threshold are excluded.
Note

Hugo only indexes exact string matches. If fragments are enabled, headings within the content are also included in the comparison.

Important

The algorithm requires exact string matching to index related content.

Limitations

The effectiveness of this system depends on consistent taxonomy management:

  • Taxonomy Precision: Results require precise control over tags. Unique tags may fail to form relationships, while overly generic terms may be discarded as noise by the algorithm.
  • Manual Synchronization: Requires manual terminology alignment across all articles to ensure the exact string matching logic functions as intended.

Configuration

The system utilizes Hugo's default weight settings unless explicitly defined. For custom weighting and indexing rules, refer to the Hugo Related Content Documentation.


  1. The technical implementation is derived from the following Hugo source files:

     ↩︎

Posts referencing this article

Series: Documentation

  1. 1. Introduction
  2. 2. Getting Started
  3. 3. Color Schemes
  4. 4. Directory Structure and Assets
  5. 5. Feature Images
  6. 6. Favicon
  7. 7. Series
  8. 8. Archive
  9. 9. Search
  10. 10. Backlinks
  11. 11. Related Article
  12. 12. Rich Content
  13. 13. Markdown and Hugo
  14. 14. Customization
  15. 15. Reference - Configuration
  16. 16. Reference - Front matter
  17. 17. Reference - Icons