-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undocumented or Faulty: linking colocated assets on a slug page through template #2598
Comments
I just ran into this as well. |
as far as I understood, get_url ( path, lang="en", trailing_slash=false, cachebust=false ) is also used internally which is why is simple and optimized. the function currently supposed to only work with MD files, not the page assets (even though the documentation suggests that). The function has a fallback option to also link to the static directory, and happens to work with un-sluggified content nodes too. It feels pretty alpha to me |
Basically it's for 2 things:
To handle 2 for assets with renamed slugs, it would require detecting it's a colocated asset, load the related page and generate the permalink from there (what you need to load exactly in the GetUrl fn is TBD, you don't want to add the whole site). |
I was wondering if adding permalinks of colocated assets alongside the one of the page would be an acceptable solution. This would allow 1. to find assets through internal links which would solve the initial statement by just adding '@/' to the asset's path used in get_url. I am really new to Zola so it might be a complete non-sense and I have no idea if having much more permalinks could have a negative impact on performance. Last but not least, it would introduce a difference between If the proposed solution is acceptable, I can try to do a PR in the coming weeks. |
I think it could work.
There's no expectation that those 2 are the same once this issue is fixed. |
I tried to propose a PR which would solve this issue by using the internal resolution ('@') for assets.
Adding the lang is not mandatory but it would allow to retrieve the lang-aware permalink (i.e. with path starting with the lang) for the non-default languages. |
Documentation issue
Summary
Listing all colocated assets of a page in a template
page.html
. The contentindex.md
uses a slug(tested on versions 0.18.0 and 0.19.1)
Files linked in markdown are unaffected.
file setup:
From the documentation:
If the page also uses a custom slug variable,
{{ get_url(path=asset) }}
doesn't provide this correctly,Zola will only display the right output when the link is written like:
Maybe I overlooked something, but linking all co-located assets seems to be quite essential for building almost any kind of art or photo gallery.
Proposed solution
Either current documentation should be expanded or get_url() should include this functionality.
The text was updated successfully, but these errors were encountered: