Trim is trimming too much of a word

Hello when trimming a file path under a news collection the following outputs ws/this-is-a-test.md removing the leading “ne” if I change the collection name from news to anything else it’s trimming correctly. Why is “ne” being stripped out? I also tried trim left and same results

{{ $path := (trim "site/content/news/this-is-a-test.md" "site/content/" ) }}
{{ $path }}

Running hugo v0.88.1-5BC54738

It’s removing all the characters from the left and right that are found in the second argument, regardless of where they are. So it gets to w which isn’t in the second argument and stops removing things. You might try the replace function or strings.TrimPrefix.

3 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.