Some hints to using JSON instead of MD Files

Hello all,

Based on some threads related to using JSON instead of MD files, I am interested to try this method as I believe it will be a good learning for me.

I searched and found that if we place a JSON file in the data folder, we can use goHugo to read the JSON and process it just like the MD files.

To be honest, I am yet to try this approach out. But I have a couple of doubts ( questions?) and hope that someone from the community would help me out in understanding this approach better -

  1. When working with MD Files in content folder, I have been used to creating the list and single html files in the layouts folder and it seems to be something native to goHugo (I mean, we do not have to bother about the URLs and they almost always follow the same path/structure). But the JSON is one file. Probably I will need to create some index.html file directly in the root - but if I do so, it would only do one thing - either provide me a list or display the content (single page). So how do I tackle this?

For instance, if I had this structure in content -


My layouts folder would have a list and single .html files which would generate pages like fruits/ (this would be the list of fruits) and fruits/apple and fruits/banana (for the single.html file).

How does one accomplish the same structure when using the JSON file ? Is it something to do with redirects?

  1. The second question is related to reading from JSON and then calling a partial. In normal instances (with MD files), the . sends (or makes accessible) the content in the partial. How do we accomplish this when using JSON? Does the . still work (I doubt it would).

Thank you for taking out time to read this and providing me insights.

Have a great time.

It sounds like you want to create pages from data.

This is a simple example,

git clone --single-branch -b hugo-forum-topic-45433 hugo-forum-topic-45433
cd hugo-forum-topic-45433
hugo -s prebuild && hugo server

Sir, thanks for the URL - I will be going through that and its Part I as well in depth this weekend.

For the git Code that I downloaded. it somehow did not work out.

I think it is not the version that is causing the problem instead, I need to have a config file. Currently, I will be unable to look into it, but surely, I would try fixing this over the weekend. I felt it impolite to hold back on my reply until then.

Thanks again.
Have a great weekend.

The version is causing the problem. Either upgrade, or rename hugo.toml to config.toml.

Thank you for the suggestion. I followed the tutorial (Part 1) and it was a good learning experience. I have not yet been able to work on fixing or changing the goHugo Version, however, I have done the following - (and it seems to be working good)

The list page (above)

And the single page (above).

I downloaded a csv from Kaggle and converted it to json. And now, I have a working set of list and individual pages. But, those pages are not templated. I mean, they look very barebones skeleton HTML.

The problem I have run into now is that when I try creating a theme (using the create new theme of goHugo, I wanted to use the BootStrap framework) and then wrap the codes for taxonomy inside the {{ define “main” }} and {{ end }}, the loop does not get processed and also the theme does not seem to have any effect. Probably the theme created does not do any good for the Taxonomies (as these are not the default ones)

Here is the GitHub URL for the work this far -

It does not include the Theme and the {{ define “main” }} and {{ end }} wrappers yet.

Thanks again for being there as a mentor - someone I look up to when I am working and learning goHugo.