Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

How can I replace spaces to hyphen in taxonomies?

Started by Aki 9 years ago · 0 replies · 1420 views
9 years ago

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.

Suggested topics

Topic Participants Replies Views Activity
General · by themetman, 23 hours ago
2 40 16 hours ago
General · by Hanns Mattes, 1 week ago
0 121 1 week ago
General · by Karmalakas, 1 week ago
2 185 1 week ago
General · by Hanns Mattes, 3 weeks ago
0 235 3 weeks ago
General · by Dima, 4 weeks ago
1 211 4 weeks ago