Control where footnotes are sent

Hi, in my self-made theme I use a element, so wish I could get hugo to write footnotes in here instead of in .Content.
Is it possible, if not what should I tweak in the code to get that behavior ?

It will be easier to advise by anybody if you can clarify your question and show your code.

1 Like
<header class=layout_change id=book-title>
	<label for="show-menu"><img src="/svg/menu.svg"/></label>
	{{ partial "docs/inject/book-title" . }}
	<label for="show-toc"><img src="/svg/toc.svg"/></label>
<article id=book-content>
	{{ partial "docs/inject/content-before" . }}
	{{- .Content -}}
	{{ partial "docs/inject/content-after" . }}
<footer id="book-footer">
	{{ partial "docs/footer" . }}
	{{ partial "docs/inject/footer" . }}

My question is pretty self-explanatory. Can we direct where (in what html elements) the footnotes in .Content are generated, that is, can we put them elsewhere than in .Content ?
In the actual footer of the page for instance ?

In theory, you could store the content footnotes using something like findRE and .Scratch.Set, while using replaceRE to replace it with nothing:

{{ $contentFootnotesPattern := `(<div class="footnotes" role="doc-endnotes">(?:.|\n)+?.*?</div>)` }}

{{ $contentFootnotesContent := index (findRE $contentFootnotesPattern .Content) 0 }}

{{ .Content | replaceRE $contentFootnotesPattern "" | safeHTML }}

{{ .Scratch.Set "contentFootnotes" ($contentFootnotesContent | safeHTML) }}

And finally render it in the footer:

{{ .Scratch.Get "contentFootnotes" }}

Perhaps the Hugo team should consider providing partial renderings, only content without footnotes, that would allow for much more modularity in people’s websites.

Footnotes are a Markdown thing, not a Hugo thing, so your question might be better aimed at the Goldmark team.

So .Content is created as a block by the Goldmark engine… Ok, I’mma ask then :slight_smile:

1 Like

Look at this exemple:

11. Joshua van Ee in [Was Adam Created Mortal or Immortal? Getting Beyond the Labels ?](


This: :leftwards_arrow_with_hook:︎, I didn’t code for it. But it’s not ::after pseudo-element so I can’t change it, it’s the content of a link, just written after the footnote itself. The 11. is good. But that 12 that you see is not the start of another note which would be empty. It’s a ::marker of the backref link, and it wasn’t there when the footnotes were still part of the .Content.

I don’t think Goldmark is the issue here.