Hugo explained

I found a few great articles about Hugo:

Hugo .Scratch explained

Hugo Template Language

Hugo Page Resources

Tnx to the author @regis

10 Likes

really nice, thanks for the links!

You’re very welcome, thanks for the shoutout!

1 Like

Great - thx

@regis,

You say:

What about ternary operators, x ? x : y ?

Not in Go you don’t :confused:

Hugo added a cond function for ternary operations in v0.27, but the docs haven’t been merged.

Thanks for the tip @moorereason! Can’t wait to play with it and update the article :wink:

Any Lisp fans out there?

Being familiar with Lisp, I found the Go Templates syntax very intuitive… the idea is simple… (FN ARG1 ARG2 .. ARGN)… it doesn’t matter what function it is… the function keyword always comes first. And that translates in Go Templates as {{ FN ARG1 ARG2 .. ARGN }}.

If not lisp, but familiar with RPN calculators, then too, it’s the same idea… (+ 1 2) instead of 1 + 2.

The beauty in the Go templates comes when you pipe stuff with “|”. I think that is Rob Pike’s construct. Sadly we have many template funcs that has a “less than optimal” argument order, which is hard to fix without breakage.

It’s been updated. Thanks again!

2 Likes