TIL

    A fun part about how I’m approaching the switch to micro.blog is that I’m working on it in 30 minute chunks here and there. Today I stumbled through how to work with Hugo templates to display categories:

    {{ if .Params.categories }}
      {{ delimit .Params.categories ", " }}
    {{ else }}
      Post
    {{ end }}
    

    The learning portion of this is that the Hugu/micro.blog templating language is completely unfamiliar to me. Is .Params.categories nil when empty, or is it sometimes an empty array? Can I treat it as nullable, or do I have to check array length? Can I just call delimit without any safety checks?

    What I think I can rely on so far:

    • .Params.catagories is nullable
    • .Params.catagories is nil when empty, and if should be reliable
    • delimit will not guard against nullable values

    I’ve made a tiny bit of progress towards migrating to micro.blog. I’ve forked a theme and set the background to glorious #0000FF.

    Screenshot of a website