Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

How can I replace spaces to hyphen in taxonomies?

Started by Aki 8 years ago · 0 replies · 659 views
8 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 Jerry Hunt, 4 days ago
2 80 9 hours ago
General · by pamtbaau, 14 hours ago
1 51 14 hours ago
General · by Andy Miller, 1 day ago
0 44 1 day ago
General · by Marcel, 12 months ago
6 346 5 days ago
General · by Duc , 5 days ago
3 40 5 days ago