Render List Datafile with YML

Please explain how to create a list in this way but can not?

EXAMPLE

/data/person/author.toml

name = "Name 1"
job = "Job 1"
extra = "bla bla"
  
name = "Name 2"
job = "Job 2"
extra = "bli bli"

/themes/theme-hugo/layouts/index.html

{{ range .Site.Data.person }}

<ul>
<li> 
Name : {{ .Name }}
Job : {{ .Job }}
Extra : {{ .Extra }}
</li>
</ul>

{{ end }}

OUTPUT

Name : Name 1
Job : Job 1
Extra : Bla Bla

Name : Name 2
Job : Job 2
Extra : Bli Bli

But it did not render

1 Like

Hello @sandyartha92,

in TOML you can aggregate multiple values, i.e. the attributes for the an author, with a table:

[author-1]
name = "Name 1"
job = "Job 1"
extra = "bla bla"

But you want an array of authors, so we’ve to create an array of tables:

[[authors]]
name = "Name 1"
job = "Job 1"
extra = "bla bla"

[[authors]]
name = "Name 2"
job = "Job 2"
extra = "bli bli"

Within the template you can range over this array as follows:

{{ range .Site.Data.person.authors }}
2 Likes