[SOLVED] Untyped nil error and always errors trying to make a string


I made a terrible, terrible mistake, there was a single other content .md file without the parameter there which I had forgotten about, and of course it was causing the error.

ERROR 2018/02/19 19:01:16 Cannot read json from resource ./data/ with error message unexpected end of JSON input

Not sure what you’re trying to do, without a link to a repo and site. Two quick things come to mind: your json validates of course? The “curly quotes” in your example are an artifact of cut-and-paste I assume?

Please contribute some documentation if you figure it out.

Yes the curly quotes are from copy pasting.

I dont really even care what the function is, getjson just happens to be the one im using. I find that when I pass a hardcoded string into getjson, it of course accepts it. But I want to be able to pass a page parameter into it, from front matter, so I can generate different data for each page.

I cant find any way of doing that, I thought you were meant to use printf to convert stuff to strings, and I also tried the string function, but neither of them work.

Absolutely anything I pair with a hardcoded string works, like

{{ $x := (printf “%s” “./data/page.json”) }}
{{ $way := getJSON $x }}

Generalised question:
Lots of hugo functions, like getjson, accept a string. How do I pass in variables, like page parameters?

And also, what I find with Hugo as I use it, is that its totally inconsistent and fragile. For here, passing in .Title, (a front matter variable), works fine in getjson. But other front matter doesnt work no matter what I try.