Possible to write custom | filter?

I was not able to find information on if it is possible for me to write a custom Hugo | filter? I wrote a shortcode that I’d also like to apply to content like: {{ .Title | markdownify | emojify | myCustomFilter }}

Sorry in advance if it’s in the docs. Maybe I’m searching for the wrong keywords “hugo custom filter”?

The only current way is to create a partial template that returns a value, which can be inlined or put in a file below /layouts/partials, e.g:

[quote="mhulse, post:1, topic:41900"]
{{ .Title | markdownify | emojify | (partial "tolower") }}

{{ define "partials/tolower" }}
{{ return (. | lower) }}
{{ end }}

I just typed the above, so there may be mistakes …

1 Like

Thank you! I really appreciate your help and code example!

1 Like

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