How can I replace spaces to hyphen in taxonomies?


#1

Hi, I’d like to replace %20 in taxonomies’ url to dash/hyphen.
for example,
mysite.com/blog/tag:apples%20and%20oranges
to
mysite.com/blog/tag:apples-and-oranges

I tried adding | hyphenize onto taxonomylist.html.twig. but it doesn’t work.

a class=“label label-rounded {{ label_style ?: ‘label-secondary’ }} p-category” href="{{ blog.url|rtrim(’/’) }}/tag{{ config.system.param_sep }}{{ tag | hyphenize }}">{{ tag }}</a

actually, url was changed to tag:apples-and-oranges, but when I click the taxonomy label, grav shows no content. But I have some posts with the tag ‘apples and oranges’.

I don’t want to use hyphened tag name. Tag names have spaces and only urls are hyphened, those are what I want.

Would you please tell me what part of code should I change, please?

Thank you.