Hello,
I’m running mad trying to work on some json files.
To narrow my problem, i ended on creating simple things, and 2 same files gives 2 different results … Any tip/help/enlightment welcome (I guess it is not a bug)
- 2 exact same .json files
test1.json
& test2.json
inside /data
folder:
{
"nom" : "Martin",
"age" : "23 ans",
"ville" : "Paris",
"domaine" : "foo, bar"
}
Test 1
<ul>
a
{{ range .Site.Data.test1 }}
<li> {{ . }}</li>
{{ end }}
b
</ul>
Test 2
<ul>
c
{{ range .Site.Data.test2 }}
<li> {{ . }}</li>
{{ end }}
d
</ul>
My test :
{{% test %}}
And the result is :
Test 1
a
23 ans
HTML, CSS, JavaScript
Martin
Annecy
b
Test 2
c d
And i also tried to do test2 before test1, but same problem. test2.json doesn’t render
And i’m on v0.31.1 darwin/amd64
uhhhh, I guess i’m doing some Rubber duck debugging on this case because, cleaning my example, shows that even reloading hugo, my result page is based on old content (difference between content json and result)
Is there some hidden cache for json ?? I can’t find anything on the doc about this.
EDIT : Forget about this. The render file1 is ok with the result. Still original problem.
hugo server --disableFastRender --buildDrafts --ignoreCache
Try using --IgnoreCache on build.
And yes, data files I believe are cached. Sometimes I just delete the Hugo Cache folder myself, as building with IgnoreCache can cause the build to take a while if you use lots of data files \ iterations.
Thanks for the response. No more difference, but original pb still accurate.
Found the origin of problem.
VisualStudioCode seems to append 3bytes ef bb bf
in some case. Thay call that UTF8-with_BOM !! (wtf ?)
myaccount$ hexdump test1.json
0000000 7b 0a 22 6e 6f 6d 22 20 3a 20 22 4d 61 72 74 69
0000010 6e 22 2c 0a 22 61 67 65 22 20 3a 20 22 32 33 20
myaccount$ hexdump test2.json
0000000 ef bb bf 7b 0a 22 6e 6f 6d 22 20 3a 20 22 4d 61
0000010 72 74 69 6e 22 2c 0a 22 61 67 65 22 20 3a 20 22
Removed this strange according and it works.
I don’t know if hugo should take care of those strange UTF8 files ? Anyway, hope this will help others.