I’m currently developing a one-page website using Grav CMS and I’m facing an issue with generating URL slugs that include Polish characters. I’m using Twig’s hyphenize
filter to create slugs for the navigation menu, but it does not handle Polish diacritical marks correctly. For example, “O firmie ąś” becomes “o-firmie-%EF%BF%BD-%EF%BF%BD” in the URL.
Here’s the Twig code snippet I’m using for the menu:
{% for module in page.collection() if module.header.visible is not same as(false) %}
<li class="nav-item">
<a class="nav-link scroll" href="#{{ module.menu|hyphenize }}">{{ module.menu }}</a>
</li>
{% endfor %}
I need a solution that can properly translate Polish characters into standard ASCII characters for URLs (ex. “O firmie ąś” => o-firmie-as). Could someone suggest a method or a custom Twig filter that would handle this properly? Any advice or examples would be greatly appreciated.