# Shortcode and footnotes

**URL:** <https://discourse.gohugo.io/t/shortcode-and-footnotes/43832>\
**Category:** support\
**Created:** [April 10, 2023, 3:59am UTC](https://discourse.gohugo.io/t/shortcode-and-footnotes/43832 "2023-04-10T03:59:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![techmagus](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/techmagus/32/16997_2.png) [@techmagus](https://discourse.gohugo.io/u/techmagus)\
**Post date:** [April 10, 2023, 3:59am UTC](https://discourse.gohugo.io/t/shortcode-and-footnotes/43832/1 "2023-04-10T03:59:53Z")

</div>

Continuing the discussion from [Isolation of links and footnotes inside codeblocks](https://discourse.gohugo.io/t/isolation-of-links-and-footnotes-inside-codeblocks/43795/7):

> [@Isolation of links and footnotes inside codeblocks](https://discourse.gohugo.io/t/isolation-of-links-and-footnotes-inside-codeblocks/43795/7):
>
> 1. Footnotes within a shortcode called using the `{{% foo %}}` notation are rendered as expected.
> 
> ```auto
> {{% foo %}}
> This is **bold** text.[^4]
> {{% /foo %}}
> 
> ```

I can’t make this work.

This is my shortcode:

```auto
{{- /* HOW TO USE
{{% quotebox boxstyle="qbs_generic" qmarkstyle="qbm_doublequotationmark" boxcolour="qbc_blue" attribalign="txt_right" citeby="" citelink="" citerel="noopener external" pubtitle="" publink="" pubrel="noopener external" %}}
content
{{% /quotebox %}}
*/ -}}
{{- /* Changelog:
  1. To avoid confusion:
    * replaced src prefix with cite
    * replaced attrib prefix with pub
  2. converted to $var
*/ -}}
{{- $boxstyle := .Get "boxstyle" -}}
{{- $boxcolour := .Get "boxcolour" -}}
{{- $qmarkstyle := .Get "qmarkstyle" -}}
{{- $attribalign := .Get "attribalign" -}}
{{- $citeby := or (.Get "citeby") (.Get "srctitle") -}}
{{- $citelink := or (.Get "citelink") (.Get "srclink") -}}
{{- $citerel := or (.Get "citerel") (.Get "srcrel") -}}
{{- $pubtitle := or (.Get "pubtitle") (.Get "attribto") -}}
{{- $publink := or (.Get "publink") (.Get "attriblink") -}}
{{- $pubrel := or (.Get "pubrel") (.Get "attribrel") -}}
<figure class="quote_box {{ with $boxstyle }}{{ . }}{{ end }} {{ with $boxcolour }}{{ . }}{{ end }}">
  <blockquote class="{{ with $qmarkstyle }}{{ . }}{{ end }}"{{ with $citelink }} cite="{{ . }}"{{ end }}>
    {{- .Inner | markdownify -}}
  </blockquote>
  {{ with or $pubtitle $citeby }}
  <figcaption class="attribution_name {{ with $attribalign }}{{ . }}{{ end }}">
    <p><cite>{{ with $citelink }}<a href="{{ . }}" rel="dct:title {{ with $citerel }}{{ . }}{{ end }}" referrerpolicy="strict-origin-when-cross-origin">{{ end }}{{ with $citeby }}{{ . | markdownify }}{{ end }}{{ with $citelink }}</a>{{ end }}{{ with and $citeby $pubtitle }}{{ i18n "quote_src" }} {{ end }}</cite>{{ with $pubtitle }}{{ with $publink }}<a href="{{ . }}" rel="dct:creator {{ with $pubrel }}{{ . }}{{ end }}" referrerpolicy="strict-origin-when-cross-origin">{{ end }}{{ . | markdownify }}{{ with $publink }}</a>{{ end }}{{ end }}</p>
  </figcaption>
  {{ end }}
</figure>

```

However, when I add footnotes, it doesn’t render if it is outside. Example:

```auto
{{% quotebox boxstyle="qbs_generic" qmarkstyle="qbm_doublequotationmark" boxcolour="qbc_blue" attribalign="txt_right" citeby="" citelink="" citerel="noopener external" pubtitle="" publink="" pubrel="noopener external" %}}
content [^some-footnote]
{{% /quotebox %}}

[^some-footnote]: this is a footnote

```

It renders like this: [Pasteboard - Uploaded Image](https://pasteboard.co/0KKOKWULRHGA.png)

My only option is to do it like this:

```auto
{{% quotebox boxstyle="qbs_generic" qmarkstyle="qbm_doublequotationmark" boxcolour="qbc_blue" attribalign="txt_right" citeby="" citelink="" citerel="noopener external" pubtitle="" publink="" pubrel="noopener external" %}}
content [^some-footnote]
[^some-footnote]: this is a footnote
{{% /quotebox %}}

```

But the footnote will be rendered inside, like so: [Pasteboard - Uploaded Image](https://pasteboard.co/q8JX4rnaHnfF.png)

- Live sample: [YourOnly.One's Hugo Test Site](https://hugo-test-site.pages.dev/footnotes-shortcodes-2023100/)
- Live sample repo: [GitHub - techmagus/hugo-test-site: YourOnly.One's Hugo Test Site](https://github.com/techmagus/hugo-test-site)

I’ve been struggling with it since last year, and only took the time to ask about it today. ^^;;

Not sure what I did incorrectly to have broken the feature.

---

<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:** [April 10, 2023, 5:39pm UTC](https://discourse.gohugo.io/t/shortcode-and-footnotes/43832/2 "2023-04-10T17:39:51Z")

</div>

1) Don’t pass `.Inner` through `markdownify` when invoking a shortcode with the `{{% foo %}}` notation. That’s what the `{{% foo %}}` notation _does_.

2) Don’t trim the white space before `{{ .Inner }}`. You have to be careful when mixing markdown with HTML. See start and end conditions in [https://spec.commonmark.org/0.30/#html-blocks](https://spec.commonmark.org/0.30/#html-blocks).

Try it:

```plaintext
git clone --single-branch -b hugo-forum-topic-43832 https://github.com/jmooring/hugo-testing hugo-forum-topic-43832
cd hugo-forum-topic-43832
hugo server

```

---

<div class="post-metadata">

**Author:** ![techmagus](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/techmagus/32/16997_2.png) [@techmagus](https://discourse.gohugo.io/u/techmagus)\
**Post date:** [April 10, 2023, 6:26pm UTC](https://discourse.gohugo.io/t/shortcode-and-footnotes/43832/3 "2023-04-10T18:26:14Z")

</div>

Ahhh!!! That’s what’s causing it. The two combination was keeping me from seeing it work. I only tried removing one but not the other.

Thank you very very much!

---

<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:** [April 12, 2023, 6:26pm UTC](https://discourse.gohugo.io/t/shortcode-and-footnotes/43832/4 "2023-04-12T18:26:34Z")

</div>

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