I am using getJSON in one of my template files, as it is only required on that page.
{{ define "content" }} {{ partial "navigation" . }}
<div class="container">
{{ $books := getJSON "url" }}
<h1>Book Recommendations</h1>
<p>
I have read a lot of books. But these {{ len $books }} books are my favourites and which i would like to recommend.
</p>
<ul class="books">
{{ range $books }}
<li>
{{ $url := index .image_url 0 }}
{{ $slicedTitle := index (split (index .title 0) ":") 0 }}
<img src="{{ $url }}" alt="{{ $slicedTitle }}" />
<h2>{{ $slicedTitle }}</h2>
{{ $authors := index .authors 0 }} {{ range $authors }} {{ range . }}
<h3>by {{ index .name 0 }}</h3>
{{ end }} {{ end }}
</li>
{{ end }}
</ul>
</div>
{{ end }}
The problem happens if the API data changes. I tried to look into setting cache in my config.toml file but I am still confused as to for which directory I should set the cache.