With some help from Nanonets for helping with OCR of the text on them, I have collected a lot of JSON files. I want to publish the recipes as a pet project and as a way to liberate a lot of great recipes from paper.
I found this resource on data templates; I can’t seem to get it working. With this step, it gives an error. (it’s below the code). I feel that I am very close to understanding how this works.
I have [these JSON files] with the recipes. My goal is to have a post per recipe and the ability to browser on a tag (dessert, starter, etc). Demo JSON file.
Questions
Where do I place the code below? I’ve tried it with single and that resulted in the error below.
Any pointers on how to start with publishing posts with recipes are more than welcome!
{{ range $.Site.Data.jazz.bass }}
{{ partial "artist.html" . }}
{{ end }}
Rebuild failed:
Failed to render pages: render of "page" failed: "/Users/x/Desktop/HKK/HKK/themes/Blonde/layouts/post/single.html:3:6": execute of template failed: template: post/single.html:3:6: executing "post/single.html" at <partial "artist.html" .>: error calling partial: partial "artist.html" not found
Hugo env
hugo v0.89.4+extended darwin/amd64 BuildDate=unknown
GOOS="darwin"
GOARCH="amd64"
GOVERSION="go1.17.2"
Any pointers on how I can structure the posts so that they will all display a desperate recipe (input JSON or CSV)? I can collect the recipes based on the type (dessert, starter).
Unfortunately Hugo does not currently support generating pages from data files.
The way you described the issue originally it seemed like you had a separate data file for each recipe. That is why above I suggested that you move the files in the content folder and convert them to MD so that you have separate pages.
The only way to generate separate pages would be to split the JSON (or CSV) with a third party script and then perhaps it would be best to move these files (after converting them to MD) in the content directory or perhaps render each recipe with a shortcode.
See this GitHub issue, it contains some user tips about splitting a data file (make sure to expand the hidden comments).
The way you described the issue originally it seemed like you had a separate data file for each recipe. That is why above I suggested that you move the files in the content folder and convert them to MD so that you have separate pages.
That’s still the case, I have the recipes as CSV files, without a lot of effort, I can also translate them to a JSON format.
I’ll look into a bulk action from CSV to Markdown. Thanks for the link to the issue. It’s a massive thread!