Skip to content
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

Zola 0.19.1 broke get_url #2561

Open
apiraino opened this issue Jul 1, 2024 · 3 comments
Open

Zola 0.19.1 broke get_url #2561

apiraino opened this issue Jul 1, 2024 · 3 comments

Comments

@apiraino
Copy link
Contributor

apiraino commented Jul 1, 2024

Bug Report

Zola 0.19.1 broke the CI building my website.

$ zola serve
Error: Failed to serve the site
Error: Failed to render page '..../content/some-blog-post.md'
Error: Reason: Failed to render 'page.html'
Error: Reason: Function call 'get_url' failed
Error: Reason: `get_url` requires a `path` argument with a string value

Environment

Zola version: 0.19.1, Debian/trixie (current "testing" release) on Linux x86_64

Expected Behavior

get_url is supposed to keep on accepting variables, correct? I assume this is a regression because it is nowhere mentioned in the changelog (unless I am missing something).

Until Zola 0.19.0 it used to work.

Current Behavior

I use the after-dark theme where get_url is invoked with a config variable (see relevant code).

Since Zola 0.19.1 get_url only accepts strings (as the error says). If I change the template to using a string, the error disappears.

Step to reproduce

Rendering this template will emit an error:

<!DOCTYPE html>
<html lang="en">
    <head>
        <link href="{{ get_url(path=config.feed_filenames) | safe }}">
    </head>
    <body></body>
</html>
@Keats
Copy link
Collaborator

Keats commented Jul 1, 2024

get_url only accepts strings. config.feed_filenames is an array

@apiraino
Copy link
Contributor Author

apiraino commented Jul 1, 2024

Then if I read the git history correctly, this breaking change probably comes from #2477 ? If yes, why do I not get this error in zola 0.19?

I feel that this breaking change (config parameter feed_filenames) was not prominent enough. By looking at the list on linked issues and patches, this will break themes/CI, no?

@LunarEclipse363
Copy link
Contributor

The solution is to use a for loop:

<!DOCTYPE html>
<html lang="en">
    <head>
        {% for feed_filename in config.feed_filenames %}
        <link href="{{ get_url(path=feed_filename) | safe }}"/>
        {% endfor %}
    </head>
    <body></body>
</html>

Although in this specific case I would just write out each of the feeds manually because otherwise you have to handle type and title parameters in the loop which could get complicated (that is if you provide those, you really should for linking feeds), i.e.

<link rel="alternate" type="application/atom+xml" title="Example Blog - Atom Feed" href="{{ get_url(path="/atom.xml", trailing_slash=false) }}"/>
<link rel="alternate" type="application/rss+xml" title="Example Blog - RSS Feed" href="{{ get_url(path="/rss.xml", trailing_slash=false) }}"/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants