JSON data file name is a number

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.

You need to use index

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

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

2 Likes