Handling tags with special characters

What would be the best way to handle tags in the following scenario?

Tags: Café

The tag should be displayed as ‘Café’ on interface, and as ‘cafe’ on the address bar and links (/tag:cafe), and be able to filter stuff by the original tag ‘Café’.

I can’t manage to filter posts by the correct tag without having special characters encoded into a different format.

Use “UTF-8” in your input-files and as your charset of your webpages (’<meta charset="UTF-8">’).
Then you have no problems with any chars like “é” or “ä” or “€”. The panel helps you to change “é” to “e”.

You can use urlencode() and urldecode().


Thanks for the advice. I was actually looking for something closer to the Normalize function, to keep special characters or encodings away from the address bar.

Tags: Para Mamá

Displays as domain.com/section/tag:para%20mamá. So, it would be better to have that link displayed as /tag:para-mama, but that would require to process the whole tag and I don’t really know how.

For the time being, I’ll stick to urldecode and urlencode functions to have that working but I’ll keep looking for a different solution.

Is the routing function included in kirby a good path for this?

I see what you mean. The encoding part could easily be normalized, the problem is rather the other way round, because para-mama could be decoded as Para Mamá, but also as para-mama, pára-mamá, and some other options. So, is is no 1:1 correlation and you would need some sort of fuzzy logic to find the pages with the desired tag or normalize the field value before searching it.

1 Like