[SOLVED] Loop through data file with keys

How do I loop through this data file and display the quotes on each author’s page?
Author pages are named: jane-doe.md and john-smith.md in content/author
quotes.yml

--
jane-doe:
  quotes:
    - quote: "quote 1 here"
      position: 1
    - quote: "quote 2 here"
      position: 2
john-smith:
  quotes:
    - quote: "quote 1 here"
      position: 1
    - quote: "quote 2 here"
      position: 2
    - quote: "quote 3 here"
      position: 3
---

in Jekyll, I could access each like this:
{{ site.data.quotes["jane-doe"].quotes }}

Untested…

Assuming data/quotes.yml.

{{ range (index .Site.Data.quotes .File.TranslationBaseName).quotes }}
  {{ .position }}: {{ .quote }}
{{ end }}

Further Reading:


Thanks for the help. For some reasons it’s giving me a GO error, but if I hard code .File.TranslationBaseName with the actual file base name it worked:

{{ range (index .Site.Data.quotes "jane-doe").quotes }}
  {{ .position }}: {{ .quote }}
{{ end }}

So I’m guessing the error is from this line:
index .Site.Data.quotes .File.TranslationBaseName
I tried to put .File.TranslationBaseName in quotes, but still didn’t work.

This works:

{{ $author := index .Site.Data.quotes (.File.TranslationBaseName) }}
{{ range $author.quotes }}
    {{ .quote }}
{{ end }}

Thanks @moorereason

1 Like