快轉到主要內容

Backlinks

查看原始碼編輯此頁 (外部連結)
首次發表:

render-link.backlinks.json (外部連結) home.backlinks.json (外部連結)

Yore embeds a backlink system based on jmooring/hugo-module-backlinks (外部連結) to track and display bidirectional links.

Configuration 此標題的連結

Add backlinks to outputs.home to generate the backlink index, and set pageShowBacklinks: true to display backlinks on pages:

hugo.yaml
outputs:
  home:
    # The original outputs
    - html
    - rss
    # Add this line
    - backlinks
params:
  pageShowBacklinks: true

Backlinks are only detected when the link path can be resolved by Hugo's .GetPage. Simply put, you should always use syntax that includes the file extension (.md). This way, if resolution fails, you'll immediately notice that the link path includes .md, and your IDE will also be able to correctly recognize the file, enabling the jump-to-article feature to work properly.

It's recommended to use this alongside rumdl (外部連結). The MD057 (外部連結) rule can check the correctness of your links, and even supports custom root directories, allowing you to write content/posts/p1.md as /posts/p1.md while still having it checked correctly.

How It Works 此標題的連結

During rendering, Hugo's render-link hook intercepts each internal link and calls .GetPage on the destination path. If the path resolves to a page, a backlink entry is recorded in a global store that is built once per site build.

反向連結

文章關聯

無障礙設定