Inconsistent behaviour with get_url and components

Hi all, working on a small personal site with zola, and needed a simple image tag, more than the standard ![xx](...) but less than the built in image component from my theme. So I wrote this little ditty that accepts either a path or a url, adds an alt, and a simple class.

{% component aimage(alt: string, url: string="", path: string="", class: string="", @config) %}
{% if (url == "" and path == "") or (url != "" and path != "") %}
{{ throw(message = "Requires either url or path, but not both") }}
{% elif path != "" %}
{% set img_url = get_url(path=path, cachebust=true) %}
{% elif url != "" %}
{% set img_url = url | escape_html %}
{% endif %}
<img src="{{img_url}}" alt="{{alt|escape_html}}" class="{{class | escape_html }}" {% if config.markdown.lazy_async_image %} decoding="async" loading="lazy" {% endif %} />
{% endcomponent %}

and I noticed something interesting while testing it. Look at these four lines:

{{<aimage path='@/cookies/anubis.webp' alt="A picture of anubis" class="cookies" />}}
{{<aimage url='/cookies/anubis.webp' alt="A picture of anubis" class="cookies" />}}
{{<aimage url={get_url(path='@/cookies/anubis.webp', cachebust=true)} alt="A picture of anubis" class="cookies" />}}
<img src="{{get_url(path='/cookies/anubis.webp', cachebust=true)}}" alt="A picture of anubis" class="cookies" />

In theory, three should produce the exact same line, and 1 should just be a link to the image, unmodified. However, this is the output that gets rendered:

<img src="http://127.0.0.1:1111/cookies/anubis.webp" alt="A picture of anubis" class="cookies"  />
<img src="/cookies/anubis.webp" alt="A picture of anubis" class="cookies"  />
<img src="http://127.0.0.1:1111/cookies/anubis.webp" alt="A picture of anubis" class="cookies"  />
<img src="http://127.0.0.1:1111/cookies/anubis.webp?h=7eaf5ecd666f0a53978c" alt="A picture of anubis" class="cookies" />

Only one of them has a properly cachebust’ URL, even though three of them were rendered with cachebust=true.

Here’s some extra data, and I’ll provide anything else you ask for tomorrow when I get on.

PS C:\Users\aarcane\Workspace\website-2027> zola --version
zola 0.23.6
PS C:\Users\aarcane\Workspace\website-2027> zola serve
Building site...
-> Creating 7 pages (0 orphan) and 3 sections
Done in 451ms.

Listening for changes in \\?\C:\Users\aarcane\Workspace\website-2027\{zola.toml,content,sass,static,templates,themes}
Press Ctrl+C to stop

Web server is available at http://127.0.0.1:1111/ (bound to 127.0.0.1:1111)

installed with $ winget install getzola.zola.

Other than that, I’m loving working with Zola so far! The website documentation could use some updates, but it’s pretty excellent! Thanks for the great project!

The issue is that get_url currently skips paths starting by@/for cachebust as it was historically just for content with nothing to cachebust. Since we’ve added colocated asset resolution, it looks like I forgot to add cachebusting there. It should be easy to fix.

Other than that, I’m loving working with Zola so far! The website documentation could use some updates, but it’s pretty excellent! Thanks for the great project!

Thanks! I’m planning a full rewrite of the documentation site with 0.24 but taking a small break before starting the effort there

I’ve fixed the get_url issue in the next branch, that will be in 0.24

That’s awesome, I didn’t even see that discrepancy in my calling of get_url, nice catch! And the turnaround time on the fix is so freaking fast, that’s awesome, thank you!