.Site.Data is just empty map[]

#1

Hi

I have put this simple test.yaml inside the data folder:

title: myTitle    
content: myContent  

Then in my template I want to see what’s in the {{ .Site.Data }}
and it just gives back this:

map[]

This is also empty:

{{ range .Site.Data.test }}

Did I miss something?

#2

Hi,

Those work for me when I test it. We will need to see more code to be able to say why it is not working for you, please see Requesting Help

2 Likes
#3

Strange. I did the exact same steps as in this video:

I put a json file with this content inside of /data/states.json
json file: https://gist.github.com/jpriebe/d62a45e29f24e843c974

then i just put this inside single.html

{{ range .Site.Data.states }}
    {{ .name }}
{{ end }}

{{ .Site.Data}}

The only thing that happens is {{.Site.Data}} gives back this:
map[]

#4

What Hugo version do you get when you run hugo version ?