Jacob Kaplan-Moss

Tag: Templates

TIL: Recursion in Hugo Templates

Turns out recursion is possible in Hugo templates by define-ing blocks and then “calling” them with template. (I had thought define was only for overriding blocks from parent templates, like Django).

The use case was that I wanted to render a nested file tree, e.g.

- dir/
  - file1
  - file2
- dir2/
  - file3
  - dir3/
    - file4
    - file5

And so here’s a slimmed down version of what I figured out:

March 6th, 2024 • hugo templates

Seasoning Templates

I’m a food geek. I spend my free time contemplating recipes. I bore my friends by talking about the Maillard reaction and annoy them by saying things like, “did you know that cheesecakes aren’t actually cakes at all?” I wonder about the techniques for replacing chemical with organic leavening and vice versa. I watch the Food Network, and Alton Brown is my hero.

I cook a lot, of course, and I’ve gotten pretty good at it. However, there are still a couple of things that give me problems. One area in particular is especially vexing to me:

July 19th, 2007 • food templates