JSON data file name is a number


#1

Any reason why I can’t have a JSON data file named with a number? For example, `2017-18.json’ causes an error when I try to access it via

{{ $data := .Site.Data.2017-18 }}

The error I get is

bad number syntax: ".2017-18"

and I get the same error using an underscore in place of the dash, as well.


#2

You need to use index

{{ $filename := "2017-18" }}
{{ $data := index .Site.Data $filename }}

#3

Thank you. If I had a dollar for every time “you need to use index” was the answer… :slight_smile: