-
Notifications
You must be signed in to change notification settings - Fork 996
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
Unify the usage of path
parameter in functions
#977
Comments
By the way, I've stumbled upon this while creating a shortcode that resizes images. I wanted to link to the original image as well as the resized one, so both |
Related: #911 |
Can anyone spend some time to figure a nice way to unify them? No need to actually implement it, just think things through #1044 took the approach of actually allowing basic path and |
I ran into this issue - and #788 - during refactoring of the |
Yep, hopefully the next version will have fully consistent paths, I'm thinking about it too. |
So I think the easiest one to tackle is
I think the same should apply for |
Ha, incidentally, I already have this implemented in my local refactor :-) However, I'm not entirely sure this won't make matters more confusing. Also, there's still the issue with #788 which I'm not sure how to solve such that the overall situation is consistent. |
Also, and this is a bit of a nit, the |
Afterwards, we should also address whether or not any or all of these functions should error out if the resource is not found. |
Another issue with paths: #877 but in that case from a function output |
And #1035 is roughly the same |
Another type of paths that could be added once we resolve the existing ones: https://zola.discourse.group/t/experience-report-after-porting-my-blog/478/3?u=keats Ie a shortcut for when you have a lot of nesting and unique filenames. Not for the next version though, let's make sure that
|
In #1086 I've decided that current_path/page.path/section.path etc will have a leading Another issue is that some people want to get the URL for nested assets (#1098) but I am not sure about that. I don't think I want to force people to use leading |
Hey y'all no idea if this is related, but I'm building an rss reader and noticing that Zola-generated rss.xml files use relative links for images, meaning that they can't be viewed in the reader without me overriding the post's html. I assume the issue stems from this one, so just wanted to chime in to push for defaulting to absolute urls for (processed?) images in rss templates. Sorry if this is the wrong place to report this! Also sorry if this has been fixed, and the feeds I'm looking at were generated by an older version– I couldn't get zola to build an rss file at all, so couldn't check if it's still happening. Feel free to delete if totally irrelevant. |
At least on my site (built with 0.11, https://www.vincentprouillet.com/rss.xml) some images are absolute and some are relative. I will check why later, that's a bit odd. |
From what i understand Relative links to the website's root is also what we want when referencing stuff in the static folder. Couldn't we use this symbol for both cases, and error when an @/link points to a missing ressource (either in content/ or static/) ? |
Ok so in my blog, if I use markdown images it gets the full permalink but I was using a shortcode for clickable images where I was using relative links, I've just changed it and now all my image links are absolute. @southerntofu can you expand? Do you mean only allowing |
@Keats I don't think "/" should reference the site's webroot, otherwise how do you reference the actual virutalhost's webroot? In my view, starting from the site's webroot is what the In my view, we could have something like this in the context of
Two caveats:
For the first problem, i had written a simple patch which was not merged for good reasons: assets should not be copied many times in many output folders. An alternative way is by generating symlinks instead of copying the files: this would make me happy, but would not be portable to all platforms. Another way is in the path resolution process (in markdown.rs), but then it means we need to expose assets/parenthood information to this rendering process somehow? Yet another way is #840, by having pages exported to the same folder as the section, all pages in a section can link to the same assets, but this does not solve the problem for people who do not want "ugly URLs". For the second problem, there is one way i mentioned before for templates by exposing a Maybe unified path resolution could address both caveats? However, a concern is what to do when there is a missing piece of content or translation? Currently, zola will not complain for "wrong" relative URLs in a page. That's good on one hand because assets can be dynamically generated outside of zola's reach, placed in the right folder, and will become available after site generation (that's how relative URLs work in HTML). On the other hand it's bad because it does not catch typos in assets names (unless you use a full internal link). Maybe different strategies in how to deal with failed resolution apply to different situations? If we unify path resolution, we'll make a lot of things easier, but we still need control over whether a missing translation or a missing piece of content should produce an error, a warning, and/or have a fallback. For markdown resolution, this could be inherited from a section and be overwritten on a per-page basis. Something like Additionally, if templates can silently detect failed resolution, it can introduce new usecases like:
What do you think? |
I think it makes a lot of sense, but I need to think more about the i18n cases and it can be a bit separated from this issue. I think the main issue here is |
Ok time to actually work on that so it finally makes sense and to handle i18n better. How does that look to everyone?
The idea is that it should be easy to:
Next steps are to write some tests for every issues mentioned and see if the above would solve them. [ I'm also a bit unsure on where to allow Any thoughts? |
I've started work on #1455 |
The state of #1455 which I will merge soon:
Now for the paths themselves, all the functions working on files ( /// 1. base_path + path
/// 2. base_path + static + path
/// 3. base_path + content + path
/// A path starting with @/ will replace it with `content/`
In the PR state, this means that pretty much anything starting with A few questions remain:
What do people think? |
Good question, don't know exactly what would be best right now either. I've pulled your branch and I'm having a look. Will try to figure out something... |
@Keats How about we make both Edit: So many typos, sorry Edit2: I am willing to implement this, I've been procrastinating on the imageproc cleanup long enough and I've just finished some other stuff, so I should be able to get around to it finally... |
That's a good idea! If you can do the PR on #1455 it would be great Edit: wait, how would do know the sizes with something like a |
I think that should be computable from the input |
@Keats FWIW, I'm working on it, about half way through, will try to report back asap with something... Edit: WIP commits in my |
Cheers, take your time we're not in a hurry. What do you think of the other functions change? Does it make more sense now? |
@Keats I've created a PR at #1484. The changes aren't documented yet, I suppose I would update the doc after we figure what the end result is going to be. I think overall the change makes sense as far as I understand. Does the |
Look at the comment in #977 (comment) rather than the table it should be clearer. I'll have a look at the PR |
Does this new implementation address the use case presented in #1161 around Specifically, being able use a shortcode and use it in Markdown like so: Markdown -
Template -
Or do we still need to use the |
You will still need to use the |
It's all available in the |
@vojtechkral any reason we are not caching get_image_metadata response? I can add that if it's ok |
@Keats Missed the notification, sry. Anyway, no reason, agreed it would be a good idea to cache it. Not sure if I can get to it sooner than next weekend :/ |
Ah I didn't mean you need to be the one to do it, I can do it myself! Just wanted to double-check it makes sense |
Any idea when the I'm trying to access images in the |
Maybe next week? Just trying to find bugs and fix them before release. You can try the |
Should be fixed in 0.14 which is now released! Thanks all for the feedback and please open issues if you encouter bugs or weird things. |
The
path
parameter is used in multiple functions that Zola adds to the Tera templating engine, likeget_url()
andresize_image()
, as well as in Markdown links like[link](path)
. However, the way that they resolve the path seems to differ between them.For example,
get_url()
seems to do a lookup instatic/
for paths that have no leading/
or@
, and for paths that start with an@
it does a lookup incontent/
. On the other hand, bothget_page()
andget_section()
start incontent/
for paths without leading/
or@
. It is unclear from the documentation what happens with paths with a leading/
in any of these functions.mypath
@mypath
/mypath
$PWD/mypath
content/mypath
static/mypath
content/mypath
content/mypath
content/mypath
content/mypath
I propose the unification of the
path
parameter in some or all of those cases. Let's discuss!The text was updated successfully, but these errors were encountered: