Hi, I wonder how template functions are called in Hugo. I’ve added a new function in ‘template.go’ called Substr and created an alias inside init() function at the bottom like “substr”: Substr, just like the other functions. I’ve also written a test for it in ‘template_test.go’ and it passed fine. Then I rebuilt hugo as the following:
go build -o hugo main.go
mv hugo /usr/local/bin/
But when I tried to re-launch the server again in one of my existing Hugo project like this:
hugo server -w -v
I’ve got an error saying ‘function “substr” not defined’. Not sure what have I done wrong. I’m pretty new to Golang.
This suggests that the Hugo you build with isn’t the Hugo you modified.
I suggest making a cosmetic and visible change to some existing Hugo functionality and verify that your change gets applied.
Then I would look at the Go build setup. Most likely a GOPATH issue (I’m still a little bit confused by this myself, but I suspect what you see is the Hugo source fetched via “go get”)).