getzola / zola

A fast static site generator in a single binary with everything built-in. https://www.getzola.org
https://www.getzola.org
MIT License
13.56k stars 946 forks source link

Taxonomy containing a locale string breaks taxonomy_list links #2621

Open BenjaminAndre opened 1 month ago

BenjaminAndre commented 1 month ago

Bug Report

Environment

Zola version: 0.19.2

Expected Behavior

If I write (in a template but probably in most places)

<a href="{{ get_url(path='genres', lang=lang) }}">
    Genres
</a>

I expect the French (main language) to link to root/genres, and the English secondary language to link to root/en/genres

Current Behavior

The English version leads also to root/genres just like the French version. Which, for the user, looks like he falls back to French.

Step to reproduce

Since my other taxonomies (tags and authors) don't have the same problem and I investigated a little, I suspect it's the en in the taxonomy (genres) that causes the problem. I'd bet it messes up a regex somewhere in the get_url macro.

Keats commented 1 month ago

It looks like lots of people (https://github.com/getzola/zola/issues/2598) are confused about get_url so it should probably be changed.

Here's a short version of what it does: https://github.com/getzola/zola/issues/2598#issuecomment-2288543960

It should probably be split into several functions rather than one function searching through many things.