Parsing Backlinks in Hugo

Assuming we limit the scope to links in markdown, here is one idea:

  • In a render hook, find the page (site.GetPage) and add the current page to a Scratch “backlinks map” in the target page.
  • In a dummy output format that is rendered first, do a {{ range site.RegularPages }}{{ $tmp := .Content }}{{ end }}
  • Then you should have a ready-to-use backlink index in your Page.Scratch (or Page.Store depending on your requirements) when you render your HTML (or RSS).