Percent-encoding for slugs

I’m trying to use Zola for my blog in Japanese and happy except for one problem. I have trouble with taxonomies including Chinese characters (Kanji). Zola’s slugs are based on Chinese pronunciation, so they are unreadable for Japanese. In fact, because Kanjis in Japanese have many pronunciations depending on the context, it is difficult to slugify them correctly. Therefore, “on” option of slugify is not appropriate for Japanese.

“safe” slugify in Zola generate URLs including non-ASCII characters. Web browsers encode them and access percent-encoded URL, so reach the 404 page. It is not usable.

Therefore, for Japanese documents, URL of a taxonomy entry $BASE_URL/$NAME/$SLUG should be percent-encoded. Web browsers decode them to display URLs, so that we have correct Japanese notations.

Are there any option to use percent-encoding in Zola?

I think it’s a bug safe and off should work for all languages. I think it’s because permalinks are generated in the config that this was skipped during the initial implementation.

In the meantime, I think you can do things like {{ page.permalink | urlencode }}. The next release will focus on i18n, which has taken a backseat for a bit too long right now.

2 Likes

Thank you for your reply! I’ll try your advice tomorrow.

I realized that Zola version 0.10.1 seems to work with non-ASCII taxonomies correctly.
Zola version 0.12.2 does not.

I’m looking forward to the next release.

That’s really weird… It must be a regression then since I don’t think there were any intentional changes to slugification since then. If you can write a failing test for zola I can bisect. Otherwise I’ll try to come up with the test myself.

I was going to release the next version any day now but I want to see if I can squeeze that in first.

Here is a minimum example. Please see README for usage.

My environment: Edge (Chromium) and Firefox on Win10, Zola 0.10.1 and 0.12.2 on WSL1 (Debian).

Thanks! I think it’s a bug in the new way we serve data in zola serve. If you do zola build, you can see everything is as it should be. It should be an easy fix, i’ll investigate and fix it asap.

That’s fixed in the next branch: the zola serve server was not actually percent decoding the path and was thus trying to get the wrong key.

1 Like

Thank you for your kind response and quick fix! The “next” branch works as I expected. Excuse me for my poor English.

Your English is great don’t worry! Much better than my Japanese when I was living there :stuck_out_tongue:

1 Like