# Footnotes rendering from within a partial?

**URL:** <https://discourse.gohugo.io/t/footnotes-rendering-from-within-a-partial/26654>\
**Category:** support\
**Tags:** footnotes\
**Created:** [July 2, 2020, 8:53am UTC](https://discourse.gohugo.io/t/footnotes-rendering-from-within-a-partial/26654 "2020-07-02T08:53:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrwonka](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mrwonka/32/6646_2.png) [@mrwonka](https://discourse.gohugo.io/u/mrwonka)\
**Post date:** [July 2, 2020, 8:53am UTC](https://discourse.gohugo.io/t/footnotes-rendering-from-within-a-partial/26654/1 "2020-07-02T08:53:40Z")

</div>

I’m trying to include a footnote in a partial I’ve created. The partial is super simple and essentially just wraps the {{ .Inner }} in a `div`. Something like this:

```go
<div class="callout">{{ .Inner | markdownify }}</div>

```

```go
{{< callout >}}
This is my content
{{< /callout > }}

```

This seems to work for most things I throw at it… except footnotes. Which completely fail to render. ☹

As a dev I can see _why_ this might be the case but I don’t think it really should be intended behaviour? I tried to solve it by turning unsafe markup on and simply including the div html in my post markdown but then the renderer failed to process any markdown I had between the two `div`s.

Is there a potential solution?

---

<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:** [July 2, 2020, 3:42pm UTC](https://discourse.gohugo.io/t/footnotes-rendering-from-within-a-partial/26654/2 "2020-07-02T15:42:19Z")

</div>

Please show a complete example of your markdown, where the _shortcode_ is used in conjunction with footnotes.

---

<div class="post-metadata">

**Author:** ![mrwonka](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mrwonka/32/6646_2.png) [@mrwonka](https://discourse.gohugo.io/u/mrwonka)\
**Post date:** [July 7, 2020, 3:54pm UTC](https://discourse.gohugo.io/t/footnotes-rendering-from-within-a-partial/26654/3 "2020-07-07T15:54:50Z")

</div>

Mmm. Bit difficult without a lot of cruft but I hope this clarifies.

```auto
{{< callout >}}
This is my content with a footnote[^1]
{{< /callout > }}

[^1]: This would be the footnote that you see.

```

I’m expecting to see on my page:

```auto
<div class="callout">
<p>
  This is my content with a footnote
  <sup id="fnref:1">
    <a href="#fn:1" class="footnote-ref" role="doc-noteref">
      1
    </a>
  </sup>
</p>
</div>

<section class="footnotes" role="doc-endnotes">
<hr>
<ol>
  <li id="fn:1" role="doc-endnote">
    <p>
      This would be the footnote that you see. <a href="#fnref:1" class="footnote-backref" role="doc-backlink">↩︎</a>
    </p>
  </li>
</ol>
</section>

```

What I actually get is:

```auto
<div class="callout">
<p>
  This is my content with a footnote[^1]
</p>
</div>

```

Notice that not only does the link not get created but the footnote section is entirely missing.

---

<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:** [July 7, 2020, 5:47pm UTC](https://discourse.gohugo.io/t/footnotes-rendering-from-within-a-partial/26654/4 "2020-07-07T17:47:56Z")

</div>

You’ll have to do this instead:

```html
{{< callout >}}
This is my content with a footnote
{{< /callout > }}[^1]

```

You will also need to prevent the superscript from jumping to the next line. You could do either of these in your shortcode:

1. Style the `<div>` to display inline.
2. Use a `<span>` instead of a `<div>`. For example:

```html
 <span class="callout">{{- .Inner | markdownify -}}</span>
 {{- /* This comment trims trailing whitespace. */ -}}

```

This question has come up before:

> [@Footnote anchor inside shortcode](https://discourse.gohugo.io/t/footnote-anchor-inside-shortcode/2742):
>
> Anyone had success placing a footnote using the blackfriday markdown syntax inside a shortcode? The shortcode syntax processing occurs prior to blackfriday, so this seems possible, just not familiar enough with the internals to understand the sequence exactly. – ex: {{% block %}} text one [^1] {{% /block %}} ... [^1]: ref one – more complex ex: {{% block %}} text one [^1] {{% /block %}} text two [^2] ... [^1]: ref one {{% refblock %}}inner one{{% /refblock %}} [^2]: ref two – basic bloc…

---

<div class="post-metadata">

**Author:** ![anon94623599](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@anon94623599](https://discourse.gohugo.io/u/anon94623599)\
**Post date:** [March 27, 2021, 8:17pm UTC](https://discourse.gohugo.io/t/footnotes-rendering-from-within-a-partial/26654/5 "2021-03-27T20:17:14Z")

</div>

I believe the issue is that the markdown rendering in a shortcode via

```auto
{{ .Inner | markdownify }}

```

only renders the markdown with local context, i.e., without the full document containing all the footnotes.

What worked for me is to define the shortcode as follows without markdownify and **with** the linebreaks:

```auto
<div class="callout">
{{ .Inner }}
</div>

```

and then use the shortcode as follows (see [Shortcodes | Hugo](https://gohugo.io/content-management/shortcodes/))

```auto
{{% callout %}}
This is my content
{{% /callout %}}

```

Because of the `%` delimiters markdownify is not needed and the content is rendered with global context. The new lines in the shortcode somehow have an impact on what is rendered as markdown and what left as html.

Additionally, I use the configuration

```auto
markup:
  goldmark:
    renderer:
      unsafe: true   

```

I am quite new to Hugo so I don’t have full understanding here, but still hope it is helpful.

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [March 28, 2021, 12:34am UTC](https://discourse.gohugo.io/t/footnotes-rendering-from-within-a-partial/26654/6 "2021-03-28T00:34:52Z")

</div>



---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [March 28, 2021, 12:38am UTC](https://discourse.gohugo.io/t/footnotes-rendering-from-within-a-partial/26654/7 "2021-03-28T00:38:22Z")

</div>

@anon94623599 Please do not keep bumping up old topics, especially those several years old. Please do not keep posting essentially the same response to multiple topics. Please read [Help keep this forum practical](https://discourse.gohugo.io/t/help-keep-this-forum-practical/31644) .
