On my website I want to show in the footer a list of 8 posts from the same top category, but in a random like nature. Otherwise, I’ll have 100+ posts with all the same “More posts” list in the footer.
I know Hugo has no random list function, but is it possible to get a list that’s at least not the same on every page? It doesn’t need to be more random than that for me. Perhaps something with mod and .Relpermalink? (I was thinking in that direction but don’t know how to make it concrete)
I’d like to revisit this topic to see if there’s an interest in creating a Hugo feature that generates a list of random post from a certain taxonomy.
There has been talk about related content in another thread, but it seems to me that a random list of posts is (a) much easier to implement and (b) run much quicker than processing the content itself and use an algorithm to determine if the content is like other content.
Of course, it does depend on someone’s site structure how good this approach works, but for most websites that order content with categories and/or tags, a random list of posts with the same taxonomy would serve as a good related content list, I think.
I was thinking about something like this:
{{ range first 10 (where .Data.Pages.Random "Section" "post") }}
{{ .Title }}
{{ end }}
I don’t know Go programming, but it seems to me that if .Data.Pages.ByDate is possible, generating a list with a command like .Data.Pages.Random seems doable too. The range and first commands, as well as where, are already there.
What do other people think of this; a good idea or beyond the scope of Hugo?