# \[SOLVED\] Relative path not generated for colocated assets

**URL:** <https://zola.discourse.group/t/solved-relative-path-not-generated-for-colocated-assets/2211>\
**Category:** Support\
**Created:** [July 12, 2024, 3:06pm UTC](https://zola.discourse.group/t/solved-relative-path-not-generated-for-colocated-assets/2211 "2024-07-12T15:06:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yther](https://avatars.discourse-cdn.com/v4/letter/y/5e9695/32.png) [@Yther](https://zola.discourse.group/u/Yther)\
**Post date:** [July 12, 2024, 3:06pm UTC](https://zola.discourse.group/t/solved-relative-path-not-generated-for-colocated-assets/2211/1 "2024-07-12T15:06:57Z")

</div>

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…

---

<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:** [July 12, 2024, 4:13pm UTC](https://zola.discourse.group/t/solved-relative-path-not-generated-for-colocated-assets/2211/2 "2024-07-12T16:13:41Z")

</div>

Can you make a small reproduction site?

---

<div class="post-metadata">

**Author:** ![Yther](https://avatars.discourse-cdn.com/v4/letter/y/5e9695/32.png) [@Yther](https://zola.discourse.group/u/Yther)\
**Post date:** [July 12, 2024, 4:29pm UTC](https://zola.discourse.group/t/solved-relative-path-not-generated-for-colocated-assets/2211/3 "2024-07-12T16:29:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Yther](https://avatars.discourse-cdn.com/v4/letter/y/5e9695/32.png) [@Yther](https://zola.discourse.group/u/Yther)\
**Post date:** [July 13, 2024, 1:20pm UTC](https://zola.discourse.group/t/solved-relative-path-not-generated-for-colocated-assets/2211/4 "2024-07-13T13:20:11Z")

</div>

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](https://stackoverflow.com/questions/5948659/when-should-i-use-a-trailing-slash-in-my-url)

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.
