Here's an example of a Hugo page that displays a JSON file as a table with Markdown:
code
---
title: "My JSON Table"
date: "2020-04-30"
---
You can see that the page is set up with a title, date, and a section with the Markdown --- command. Within the section, we use the Hugo jsonfile template to display the JSON file. The template takes two parameters: the name of the JSON file and the name of the table format (in this case, Markdown).
The template generates a table row for each object in the JSON file, with each cell containing the object's key and value. Here's an example of a table row:
code
| Key | Value |
|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| message | "Hello, World!" |
| age | 25 |
| occupation | "Software Engineer" |
| github username | "John Doe" |
| twitter username | "@JohnDoeDev" |
|bio | "John Doe is a software engineer who loves to travel and explore new places. He is an active member of the Open Source community and is always looking for new opportunities to contribute." |
To display the table, we use the Hugo <%- command to include the JSON file as a data source. The data is then passed to the Markdown template, which generates the table rows. Finally, we use the Hugo <%- command again to wrap the table in a <div> element and display it on the page.