Footnote references are duplicated on list pages

Pages with a list of posts that contain footnotes break the footnote links. The problem is that each post’s footnote IDs are generated starting at 1. So two posts which footnotes on the same page will both use #fn:1 as their ID which breaks the footnote hyperlinks.

The footnote IDs should be unique to the post. Maybe a hash of the footnote number + the permalink URL or similar.

If this doesn’t make sense I can put together a quick example.

I think I understand, but an example would really help.

Here’s the blog I’m setting up. There are two posts on the page, each with one footnote. Note that the ID of the footnote links are the same. So clicking the link for the 2nd post’s footnote go to the 1st post.

I’m not sure that Hugo could do anything meaningful about this, but you can do so quite easily. Instead of writing your footnote as Wrong way:[^1], write it as Wrong way:[^sadly] and match that with the footnote definition of [^sadly]: …. As long as you don’t reuse the same footnote name across posts, you won’t run into this problem.

What appears to be happening is that Hugo is generating the HTML for each post once and is reusing it wherever {{ .Content }} appears in the template. Unless Hugo were to regenerate the {{ .Content }} on each loop of a list page—increasing the generation time substantially—you will get reused footnote IDs.

According to the discussion at, I think it seems to be implemented by using unique FootnoteAnchorPrefix, for example, page title, slug or something frontmatter on each pages

That would probably work, but I’m not quite sure how to get that information from the code—yet. I’ve got an open PR that we can use to make this happen pretty easily, given that.

I’ve opened a different pull request (unique footnotes per page) that builds on the previous footnote customization pull request that does this.

I’ll be honest and say that I don’t like the code here—I think that there’s probably a better way to do it than pass around the parameters the way that I’ve done.