Trim is trimming too much of a word

Hello when trimming a file path under a news collection the following outputs ws/ 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/" "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.


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