# Templating Footnotes

**URL:** <https://zola.discourse.group/t/templating-footnotes/2986>\
**Category:** Feature requests\
**Created:** [October 13, 2026, 8:34pm UTC](https://zola.discourse.group/t/templating-footnotes/2986 "2026-10-13T20:34:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ageipert](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@ageipert](https://zola.discourse.group/u/ageipert)\
**Post date:** [October 13, 2026, 8:34pm UTC](https://zola.discourse.group/t/templating-footnotes/2986/1 "2026-10-13T20:34:34Z")

</div>

## Summary

Add the ability to use a Tera component to template the exact html generated for a footnote and/or the footnote reference.

## Motivation

I don’t like footnotes either in line at the point they were defined, they disrupt the reading flow, or at the bottom, which forces jumping up and down the page. On Desktop the screen is large enough, so that they can be to the side of the main content at the height of the footnote. To achieve this you need to use html anchors in the footnote and the reference with a custom attribute. By using a component and passing all the variables currently already used by the code for bottom footnotes it is possible to insert the required anchors and additional divs etc. to achieve my desired formatting.

[This user](https://zola.discourse.group/t/is-there-a-way-to-customise-the-way-zola-parses-markdown-footnotes/694/4) used to define his footnotes directly as html, so they could style them more easily. In the future it would be one component definition and the normal usage of footnotes.

In #3100 one user would like to make the footnotes bigger and have more control over their styling. With a component using the footnote name, eg. [^note 1] it could print [note 1] in the text instead of [1] currently. Depending on how it is implemented it would also solve their wish for custom styling.

## Guide-level explanation

To use this feature you define a component with 4 parameters. (The exact naming is up for debate, I will use the current naming in the footnote code. One could possible also pass perma-link of them as an implicited parameter.) If no component is defined, the default formatting of zola takes place.

- perma-link: The permanent link to the current page, usefull if a user copies it.
- name: the content of the angle brackets, without the carret
- n: The count of all footnotes up to this point. This is what currently get’s rendered as the footnote.
- nr: How many references exists to this footnote or the number of the reference to this footnote, depending on, if it is a reference or the footnote itself.
- body: Passed implicitly only to the footnote and contains it’s content.

If you want to overwrite the rendering of a footnote reference to the name passed in brackets you need to create a new component like this:

```django
{% component footnote_reference(perma-link, name, nr, n) %}
<sup class="footnote-reference" id="fr-{{name}}-{{nr}}">
    <a href="#fn-{{name}}">[{{name}}]</a>
</sup>
{% endcomponent %}

```

To also get the matching rendering in the footnote we need a second component for the footnote itself:

```django
{% component footnote(perma-link, name, nr, n) %}
<sup class="footnote" id="fn-{{name}}">
    [{{name}}]
</sup>
{{body}}
{% endcomponent %}

```

If the component is wrong, the default Tera error would be emitted.

There would be no need to provide a migration guide, by default the current formatting would be used and only when a component is defined it would overwrite the normal process.

Sites currently using custom footnotes could switch over to the templated footnotes. It would also guarantee the expected html every time, in contrast to manual written html. I would therefor expect the usage of this feature to help maintain pages. If you change your mind of how they should look, it would now be a single place to change.

## Reference-level explanation

[I have already implemented a draft of this RFC here, though it should be noted, that it currently doesn’t keep the output of everything before stable, so it fails some tests.](https://github.com/Tremoneck/zola/commit/d7bf1fe6151839f119a5b929dbdce92a07da0769) This is because of the difference in output between bottom footnotes and inline notes and the [] behaviour.

The only other feature it interacts with is bottom\_footnotes.

Currently if bottom\_footnotes is false the emitted cmark footnotes output is passed along to the normal generator. With this change we would need to always handle them. Depending on if a component with a name of footnotes\_reference is defined we either just call this component or use a format! path to get our old behaviour.

The same is done for footnotes themself, exepct we also need to condense the content of the footnote down to the string so we can pass it as the body.

## Drawbacks

It would make the code for the footnotes more complicated, as now we have a branch between a defined component + calling tera and just using the format! call.

The site would probably be slower to render with Tera than with format!, however I don’t this impact will be noticeable.

## Rationale and alternatives

An alternative would be to just not support this.

The other would be to build a full an more flexible scripting language into zola, this would probably go against all current goals as I understand them.

## Prior art

I couldn’t really find nice prior art of this feature.

One Jekyll theme (kau.sh/blog/henry-jekyll-theme) just uses JS to implement sidenotes.

Jekyll itself doesn’t seem to bring this functionalty itself. It might be possible to do this with a custom plugin though.

In Hugo it sometimes is emulated with shortcodes.

Here a Hugo user is abusing the image subtitle feature to get the ability to modify the footnotes. abstractnonsense.xyz/microblog/2025-08-11-writing-collapsible-inline-footnotes-in-hugo-with-markdown/

Pelican doesn’t seem to bring a footnote implementation by default, however there is a plugin written in python that creates footnotes. Python is of course a lot more powerful and easy to change to fit the wishes of the user.

In short other SSG seem to use complete scripting languages to achieve similar result, be it at runtime or at build time. This Solution would just reuse the already familiar templating already in use for Zola themes.

## Unresolved questions

Should we give the ability to emit a footnote twice, once at the position of the definition and once in the bottom\_footnote footer?

How much state should be passed down into the component as implicit state?

Do we need html escaping of any of the passed variables.

If we already modify the emitted output for footnotes, should be always the same, wether bottom\_footnotes is active or not?

Should these kind of discussion be posted here or in the github repo under the rfc folder?

## Future possibilities

I don’t have much more Ideas in this direction currently.

Think about what the natural extension and evolution of your proposal would be and how it would affect Zola and project as a whole in a holistic way. Try to use this section as a tool to more fully consider all possible interactions with the project in your proposal.

This is also a good place to “dump ideas”, if they are out of scope for the RFC you are writing but otherwise related.

If you have tried and cannot think of any future possibilities, you may simply state that you cannot think of anything.

Note that having something written down in the future-possibilities section is not a reason to accept the current or a future RFC; such notes should be in the section on motivation or rationale in this or subsequent RFCs. The section merely provides additional information.

---

<div class="post-metadata">

**Author:** ![thomasweitzel](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/thomasweitzel/32/1011_2.png) [@thomasweitzel](https://zola.discourse.group/u/thomasweitzel)\
**Post date:** [October 14, 2026, 11:51am UTC](https://zola.discourse.group/t/templating-footnotes/2986/2 "2026-10-14T11:51:38Z")

</div>

Worth knowing before investing more: in [#3100](https://github.com/getzola/zola/issues/3100#issuecomment-3834490045), Keats said he was not really planning to support footnote customization beyond the default output and `bottom_footnotes`.

[Your patch](https://github.com/Tremoneck/zola/commit/d7bf1fe6151839f119a5b929dbdce92a07da0769) looks like a useful experiment for changing ordinary reference and definition markup. I think it still renders the definition where the author wrote it, though, so it does not yet create the paragraph-level relationship that local margin notes need.

Margin notes need more than separate reference and definition components. The reference appears in a paragraph or heading, while its definition appears elsewhere. CSS or JavaScript can move the note afterwards, but then that relationship lives outside the generated HTML.

Zola would need to process the containing paragraph or heading as a unit, then emit the prose plus one or more local `<aside>` notes. That also permits normal footnote content such as several paragraphs, lists, or code, which cannot safely go inside an inline `<span>`.

[Tufte CSS](https://edwardtufte.github.io/tufte-css/) is useful prior art for the checkbox-and-label interaction, although its inline sidenotes suit short notes better than arbitrary footnote content.

As a start, I would render a note at every reference and support only paragraphs and headings. I would also reject missing or duplicate definitions and emit markup that remains useful without CSS and in print. I would avoid `:target` disclosure because it changes the URL and scroll position.

---

<div class="post-metadata">

**Author:** ![ageipert](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@ageipert](https://zola.discourse.group/u/ageipert)\
**Post date:** [October 14, 2026, 4:50pm UTC](https://zola.discourse.group/t/templating-footnotes/2986/3 "2026-10-14T16:50:41Z")

</div>

You are correct. Currently the position where it is emitted is where the footnote is defined. In the project where I’m testing this it currently looks like this:

```django
{% extends "base.html" %}

{% component footnote_reference (name, permalink, ...rest) %}
<sup id="fnref:{{name}}" data-anchor="--lf-sn-{{name}}">
<a href="{{permalink}}#fn-{{name}}">[{{name}}]</a>
</sup>
{% endcomponent footnote_reference %}

{% component footnote(name, permalink, n, ...rest) %}
<aside role="note" id="sidenote-{{name}}" data-anchor="--lf-sn-{{name}}">
<sup class=side-note-refmark>{{name}}</sup>
{{body}}
</aside>
{% endcomponent footnote %}

```

```css

<style>
aside[role="note"] {
    margin-block: 1rlh;
    color: #444;
    sup.side-note-refmark {
        position: absolute;
        right: 100%;
        top: 0;
        margin-right: .3rem;
    }

    .side-note-refmark + p {
        margin-top: 0;
    }
}

@media (min-width: 1000px) {
    sup[data-anchor] {
        anchor-name:attr(data-anchor type(<custom-ident>));
    }
    aside[role="note"][data-anchor] {
        anchor-name: --lf-sidenote;
        position: absolute;
        position-anchor: attr(data-anchor type(<custom-ident>));
        top: max(anchor(top), anchor(--lf-sidenote bottom, -1rlh) + 1rlh);
        left: 100%;
        color:inherit;
        margin: 0 2rem;
        width: 18rem;
    }
}
</style>

```

With this setup, if you’ve got enough space, you get sidenotes. At the height of your reference, or below if you’ve got several footnotes close to each other.  
If the screen isn’t wide enough, the footnote moves back to it’s posittion where it was defined.  
If you’ve got no CSS loading for reasons, it apears at the position where it was defined.

I chose this solution because it was simple and itt felt like a natural extension of zola. Currently zola doesn’t support arbitrary content in footnotes and that is not the goal of this. Just to be able to change the exact output of footnotes, so that stuff like this is possible.

Rendering the complete footnote at each position would make it more complicated, as now you would have to pass the document twice, as a footnote might get defined afterwards.

It currently works for me. If Keats doesn’t want this, I’m fine with this. I’ll just rebase sometimes for myself.

---

<div class="post-metadata">

**Author:** ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)\
**Post date:** [October 14, 2026, 8:52pm UTC](https://zola.discourse.group/t/templating-footnotes/2986/4 "2026-10-14T20:52:28Z")

</div>

Do you have a live example of what you want to do exactly? I know [Tufte CSS](https://edwardtufte.github.io/tufte-css/) but I’m just curious because some people want a hook for every element of CommonMark and the template approach is something I was thinking of.

Can you submit it as a PR in the same format as [[RFC] Merging page and section by Keats · Pull Request #3258 · getzola/zola · GitHub](https://github.com/getzola/zola/pull/3258) ? There’s the template in the master branch
