How do I use alternative template engines such as hero, or extensions like sprig?

The default template functions are quite limited. Doing some quick websearches, there are some alternatives:

But how do I use them with Hugo?

Update: Found Deprecate Ace and Amber · Issue #6609 · gohugoio/hugo · GitHub

PS: My current problem is that I need findRE but for literal strings.

I am afraid that you cannot use alternative template engines with Hugo.

We had a discussion about literal and interpreted strings in Go templates a few days ago in this topic:

Try my suggestions from that other post and see if they help you.

1 Like

My problem is not with go strings, I need to do

    {{ $re := ($.File.BaseFileName | regexp.QuoteMeta) }}

But how do I import the library in the templates?

import (

There is no plugin system in Hugo. You cannot import external Go packages.

We only have the replaceRE and findRE functions for Regular Expressions.

Wouldn’t it be a good idea to import some of the standard libraries then? E.g., regexp is very useful. Importing the standard libraries doesn’t have much overhead either, no?

The functions I mentioned above already make use of the Go regex package.

Please have a look at the doc:

1 Like