Skip to content

page.colocated_path breaks when page.path is set #2865

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

Open
opeik opened this issue Apr 22, 2025 · 0 comments
Open

page.colocated_path breaks when page.path is set #2865

opeik opened this issue Apr 22, 2025 · 0 comments
Labels

Comments

@opeik
Copy link

opeik commented Apr 22, 2025

Bug Report

For some reason, page.colocated_path evaluates to the path as if page.path wasn't set.

Here's the relevant page:

+++
title = "wtf-8"
path = "wtf-8"
+++

{{ figure(src="foo.png") }}

And the relevant shortcode:

{% if src %}
  {# If the image's URL is internal to the site... #}
  {% if src is not starting_with("http") %}
    {# ... then prepend the site's base URL to the image's URL. #}
    {% set src = get_url(path=page.colocated_path ~ src) %}
  {% endif %}
<figure class="{% if position %}{{ position }}{% else -%} center {%- endif %}">
  <img src="{{ src | safe }}" decoding="async" loading="lazy" />
</figure>
{% endif %}

Environment

Zola version: 0.19.2

Expected Behavior

Image URLs on this page evaluate to: {base_url}/wtf-8/{src}.

Current Behavior

Image URLs on this page evaluate to: {base_url}/pages/wtf-8/{src}.

Step to reproduce

@opeik opeik changed the title Weird page.colocated_path behaviour when page.path is set page.colocated_path breaks when page.path is set Apr 22, 2025
@Keats Keats added the bug label Apr 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants