How to generate a number between 1...n in Hugo

In Hugo you can use {{index (seq 18 | shuffle) 0}}.

  • What this is doing is basically making a sequence, list, of numbers from 1-18 with seq 18
  • Mixing up the list by shuffling the elements with shuffle
  • Then grabbing the first element by it’s index of zero index (seq 18 | shuffle) 0

Originally mentioned in Dev Diary 0001 - Week of October 2nd 2023

Dispatches from the fleet

What passing ships signaled back

Unfurl the messages

Pen yer reply

Scratch a message on the parchment and cast it off. After you sign in you may need to re-open this modal.