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.37k stars 936 forks source link

Link generated for relative image does not reflect intuition #877

Open timotheos-firestone opened 4 years ago

timotheos-firestone commented 4 years ago

Bug Report

Directory structure:

page.md includes the following Markdown:

![Map of Sanctuary](sanctuary-map.jpg)

On using zola serve, the HTML output for this becomes:

<p><img alt="Map of Sanctuary" src="http://127.0.0.1:1111/page/sanctuary-map.jpg"></p>

Expected HTML output:

<p><img alt="Map of Sanctuary" src="http://127.0.0.1:1111/sanctuary-map.jpg"></p>

Surely I would manually specify ![Map of Sanctuary](page/sanctuary-map.jpg) if I wanted that behaviour?

I took a look on the documentation and I couldn't find this current behaviour documented in the content overview.

It also doesn't generate any warnings that the image couldn't be found.

There's no documentation on how to reference an image that's within the same folder as the page.md, that I could see?

Environment

Zola version: 0.9.0

Keats commented 4 years ago

That's because the renderer assumes it's a colocated asset, therefore nested in the folder and prefix the page path. This is not really supported but the link should not be invalid.

itf commented 1 year ago

It is confusing that valid links in the source do not map to valid links on the output because of this issue. It seems that forcing the colocation asset assumption causes this issue. I really like #840 as a solution option for people not manually creating /folder/index.md; because with "ugly urls", both the output file and the relative links inside the file work as expected. In particular it is easier to have 2 files in the same folder sharing the same asset, rather than either having assets being fully "public" in the statics folder, or associated with a single file

Keats commented 1 year ago

It's actually a bug imo, we should not copy such a file in the public directory. You cannot share the assets, you will have to copy it once per .md file in that folder