[Resolved] How to assign my own ranges and then use them in shortcodes?

Hello all! o/

I’m trying to do a dynamic Q&A section on my website, and I would like to know how I could use my own range variables in some custom Hugo shortcodes.

For example, I would like to have a .toml file:

[[qas]]
question = "2+2 ="
answer = "4"

[[qas]]
question = "4+2 ="
answer = "6"

[[qas]]
question = "7+2 ="
answer = "9"

And then iterate on it in a Shortcode:

{{ range .Site.Data.qa.qas }}
{{ .question }}
{{ .answer }}
{{ end }}

(I don’t understand why I still haven’t nailed it…)

Please, notice that I don’t want to pollute the params.toml file. I would be very happy to store it in a dedicated file.

Don’t hesitate to teach me about good practices and how you would do it yourself, I would be very happy to also learn many approaches. :slight_smile:

EDIT : ok, I’m dumb.
I just wrote:
{{ range .Site.Data.qa.qas }}

Instead of:
{{ range .Site.Data.qa.TOML_FILENAME_HERE.qas }}

I still would be glad to have your feedbacks and suggestions about good practices, thank you! :slight_smile: