getzola / zola

A fast static site generator in a single binary with everything built-in. https://www.getzola.org
https://www.getzola.org
MIT License
13.47k stars 944 forks source link

Footnotes are not permalinked #2613

Open reujab opened 1 month ago

reujab commented 1 month ago

Bug Report

When a page summary that contains a footnote is embedded on another page, that footnote link becomes broken. This does not happen with heading references because they are permalinked; I believe footnotes should be too.

I've fixed this in https://github.com/reujab/zola/commit/e9a9bf8b3c7cdad290cede28d8ee47e52a73b37b, but I'm not sure this is the ideal solution. Let me know if I should open a pull request.

Environment

Zola version: v0.19.1

Expected Behavior

Tell us what should have happened.

The footnote should link to /permalink/#fn-1 rather than simply #fn-1, similar to heading references.

Current Behavior

Tell us what happens instead of the expected behavior. If you are seeing an error, please include the full error message and stack trace. You can get the stacktrace of a panic by adding RUST_BACKTRACE=1 when running a zola command.

The footnote is not permalinked.

Step to reproduce

Please provide the steps to reproduce the issue. If the issue is hard to reproduce, please provide a sample repository or sample that triggers the bug.

This issue can be observed on the homepage of https://github.com/reujab/knightweb.dev.

P.S. I love Zola; its design is perfect.

Keats commented 1 month ago

I believe this is the way the GitHub style footnotes are meant to be. Their spec is not updated but i've checked a few implementations and they do use local links.

I don't see a big issue with making them permalinks though? cc @totikom that implemented them, I could be missing something.

clarfonthey commented 1 month ago

Yeah, adding permalinks seems a bit excessive to me; you can make ordinary links to anchors on a page [like this](#anchor) and it doesn't permalink them. It feels like this would be inconsistent with that.

reujab commented 1 month ago

I was trying to find a way to permalink footnotes only if they are embedded inside another page, but I couldn't find a decent way to do that. I'll keep looking.

Also when I create a link to a heading [like this](#anchor), the link does become permalinked. Perhaps I'm misunderstanding.

clarfonthey commented 1 month ago

Oh, maybe I was misremembering the behaviour here. If linking #anchor on the same page becomes permalinked, then I agree that footnotes should be as well.

I had no idea that you could link footnotes across pages, either.