Hi,
I am updating my website to use hugo version 0.131.0 rather than the existing 0.92.0 version.
Hopefully the only issue I have is to phase out my use of getJSON.
So far so good and I have resolved three out of my four getJSON calls using the page resource guidance in this page.
The remaining issue I have is that I was successfully accessing JSON files in one page from another page.
My JSON files live in pages under my results sections:
results/2023-24/civilservice-summer-cup/civilservice_edsummercup_2023_24.json
results/2022-23/csbos1/csbos1_sncl_2023.json
results/2022-23/csbos2/csbos2_sncl_2023.json
When rendering pages in my news section, I used a shortcode that used getJSON to access a subset of the data from the JSON file in my results section.
{{< league_scorecards json="results/2023-24/civilservice-summer-cup/civilservice_edsummercup_2023_24.json" opp="Edinburgh West">}}
Essentially I formed a filepath to the JSON file’s location and getJSON worked just fine.
{{ $json_data_filepath := path.Join "content" (.Get "json") }}
{{ $json_data := getJSON $json_data_filepath }}
This no longer works as the revised code calls .Resources.Get (or .Page.Resources.Get) and is expecting the named JSON file to be a local resource for the news page. And is not willing to load a JSON resource from a page in the results section.
Is my only option to relocate all my JSON files from their current location in my results section to the global “assets/data” area?
I can do this but it is a pity as the results section is a convenient place to store them.
Assuming I do have to move them to the “assets/data” area, is it allowed to have a nested directory structure to help organise the files sensibly?
assets/data/results/2023-24/civilservice-summer-cup/civilservice_edsummercup_2023_24.json
assets/data/results/2022-23/csbos1/csbos1_sncl_2023.json
assets/data/results/2022-23/csbos2/csbos2_sncl_2023.json
Thanks,
Crawford.