# Question: add to footnote in a render hook?

**URL:** https://discourse.gohugo.io/t/question-add-to-footnote-in-a-render-hook/41387
**Category:** support
**Tags:** footnotes
**Created:** [November 11, 2022, 1:25am UTC](https://discourse.gohugo.io/t/question-add-to-footnote-in-a-render-hook/41387 "2022-11-11T01:25:42Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![PowerSnail](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powersnail/32/18164_2.png) [@PowerSnail](https://discourse.gohugo.io/u/PowerSnail)
#### Post date: [November 11, 2022, 1:25am UTC](https://discourse.gohugo.io/t/question-add-to-footnote-in-a-render-hook/41387/1 "2022-11-11T01:25:42Z")

</div>

I’d like to render images with titles as figures, through image render hooks, like this:

```auto
{{- if .Title -}}
<figure>
{{- end -}}

<img src="{{- $image_source.url | safeURL -}}" alt="{{- .Text -}}">

{{- if .Title -}}
    <figcaption>
        {{ .Title | .Page.RenderString }}
    </figcaption>
</figure>
{{- end -}}

```

The problem is that if the title of image contains a footnote reference, it doesn’t get rendered as a footnote, but instead, just plain text. For instance,

```auto
![image](/image.png "title[^1]")

...

[^1]: Footnote content

```

Is there a solution?

Thanks!

---

<div class="post-metadata">

### Author: ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)
#### Post date: [November 11, 2022, 1:47am UTC](https://discourse.gohugo.io/t/question-add-to-footnote-in-a-render-hook/41387/2 "2022-11-11T01:47:11Z")

</div>

Hijacking the image render hook to generate a `figure` element instead of an `img` element will produce invalid HTML. The `figure` element will be wrapped within a `p` element. That’s not allowed.

If you want to insert a `figure`, use the figure shortcode or create your own.

---

<div class="post-metadata">

### Author: ![PowerSnail](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powersnail/32/18164_2.png) [@PowerSnail](https://discourse.gohugo.io/u/PowerSnail)
#### Post date: [November 11, 2022, 2:06am UTC](https://discourse.gohugo.io/t/question-add-to-footnote-in-a-render-hook/41387/3 "2022-11-11T02:06:19Z")

</div>

Well, I suppose that it is a sort of solution, if I just avoid using render hook altogether. But I’d still like to know if there’s a way, in a more general sense, to add footnote inside a rendering hook.

---

<div class="post-metadata">

### Author: ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)
#### Post date: [November 11, 2022, 2:13am UTC](https://discourse.gohugo.io/t/question-add-to-footnote-in-a-render-hook/41387/4 "2022-11-11T02:13:58Z")

</div>

> [@PowerSnail](#):
>
> if there’s a way, in a more general sense, to add footnote inside a rendering hook

There is not. Footnotes are handled by the markdown renderer, and render hooks short circuit that.

---

<div class="post-metadata">

### Author: ![PowerSnail](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powersnail/32/18164_2.png) [@PowerSnail](https://discourse.gohugo.io/u/PowerSnail)
#### Post date: [November 11, 2022, 5:28am UTC](https://discourse.gohugo.io/t/question-add-to-footnote-in-a-render-hook/41387/5 "2022-11-11T05:28:38Z")

</div>

I see. Thanks mate.

---

<div class="post-metadata">

### Author: ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)
#### Post date: [November 13, 2022, 5:29am UTC](https://discourse.gohugo.io/t/question-add-to-footnote-in-a-render-hook/41387/6 "2022-11-13T05:29:18Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
