HUGO

Generate json for nested pages

I am really struggling to wrap my head around the concept of creating json or xml files for nested pages.

I have the following structure in my content folder

  • Content
    • Blocks
      • Footers
        • File1.html
        • File2.html
        • File3.html

Looking for a way to generate a json or xml file listing all items in the Footers directory. So that I can access it at domain.com/blocks/footers/index.json / index.xml`

[
  {
    "uri": "/blocks/footers/file1",
    "title": "File 1"
  },
{
    "uri": "/blocks/footers/file2",
    "title": "File 2"
  },
{
    "uri": "/blocks/footers/file3",
    "title": "File 3"
  },
]

Standard Section Templates apply for Custom Output Formats.

See: https://gohugo.io/templates/section-templates/#readout