[SOLVED] Relative path not generated for colocated assets

Hello,

This is my first post because it’s the first time I find no clues at all on what’s going on.

I’m not sure what is happening. I’m designing two sites, each one is based on assets collocation, and in each one I have page with an image relative path (media/my-image.webp) in the [extra] frontmatter, this path is then used in the template like this <img src="{{ page.extra.img.src }}" alt="{{ page.extra.img.alt }}/>

But I don’t know why, there is one (the oldest) that have no problem understanding the path is relative and it is well displayed in my browser, and the other one seems to understand this path as an absolute one (as if there was a leading / in the path).

I been using version 0.17.1 when designing both of them, but in my research I tested to serve both of them with the 0.19.1 binary, and the difference persists. One is working, the other not. And without any error message except GET http://127.0.0.1:1111/media/my-image.webp not found in the browser console (which is normal because link should have been http://127.0.0.1:1111/my-page/media/my-image.webp).

I don’t remember having anything to configure or having any trouble the first time to use collocated assets. Even in the documentation it seems quite straightforward, but this time I need to concatenate myself the page slug in order to get my assets.

And even with a trivial example (just <a href="test.txt">Test</a> in the index.md of a page) I can’t get to my test.txt…

I’m starting to run out of leads on the subject, do you have any idea about some configuration or some behaviour that I forgot ?

I’m sure I’m missing something, but I don’t know what…

Can you make a small reproduction site?

Yes of course (I should have done it before even if it’s trivial).

[EDIT] Remove link to the repository, because it wasn’t useful anymore.

The code of this repo doesn’t works (I can’t get the test.txt file on the second page) on my machine.

Well I found what I was missing : trailing slash on my page link…

I don’t know if I should feel stupid, because its said all over the internet that it’s good to add a slash at the end of paths if it’s not a file, or relieved that most people consider the “trailing or not trailing” question as an SEO or even a personal taste.

For the record, after noticing my mistake I did some search about this trailing slash question and found this : url rewriting - When should I use a trailing slash in my URL? - Stack Overflow

TLDR : In one of the answer someone is clarifying that relations between resources change with or without slash.

  • child relative to /parent/ is /parent/child
  • child relative to /parent is /child (this behaviour was my problem)

So I’m not sure there is something to do on zola side to prevent this except maybe a note in the “Asset colocation” section of the documentation to warn about the need of the trailing slash ?

Anyway thank’s for answering, maybe this will help other people facing the same issue.