.Site.Data is just empty map[]

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?

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

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[]

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

any updates on this issue? I’ve been haggling with this for a while.

Hugo Static Site Generator v0.76.5-60F0725B openbsd/amd64 BuildDate: 2020-10-14T15:17:56Z
GOOS="openbsd"
GOARCH="amd64"
GOVERSION="go1.15.1"

Please read Requesting Help . Follow the directions and create a new topic describing your issue. I am closing this one as it is over a year old and the OP never responded.