Taxonomy List Page 404ing on Static JSON

Greetings, I have an open source static JSON api being generated https://github.com/TuluaIO/library and its hosted at https://lib.tulua.io. I am having an issue with the “classifications” taxonomy. It’s generating the subpages fine (/en/classifications/fungus/) but the actual “list” json file isn’t being generated (/public/en/classificiations/index.json and /en/classifications/). I’ve tried creating those pages through a section template or other configs but can’t seem to generate it properly. How can I generate this file?

You need to enable it in your config.toml. Something like this:

home = [ "HTML", "JSON" ]
page = [ "HTML", "JSON" ]
post = [ "HTML", "JSON" ]

I have already tried enabling it with

taxonomy = ["json"]

and it fails to generate this page. You can also see this in the actual config.toml as well.

hmmm. how do you define “classifications”? by having a folder inside of content called classifications or did you define a taxonomy for that? First case would be a section, second a taxonomy. I would then proceed to explicitly create a template for that and see from there?

It is a custom taxonomy. I tried doing classifications = ["json"] but still no avail. I am currently doing a workaround where I am using a custom outputFormat as an index for classifications. I would really rather do the right way though. Still open to thoughts.

I just saw you linked your repo in the top post. Could have looked myself :wink:
Try adding a classifications.json in defaults. If it doesn’t work keep the template in there and I’ll load the repo tomorrow and play it through.

No worries :wink: I know how it goes.

Yeah I tried the classifications.json and classifications.json.json and still no luck :frowning:

In your case, /classifications/ is of Kind taxonomyTerm so you would need to specify the following as well:

[outputs]
  taxonomyTerm = ["json"]

…However even having added that, I still could not see public/en/classifications/index.json being generated.

So I got curious about this and did some more testing, and the only way (so far) that I have been able to generate that is by adding content/en/classifications/_index.md (as per docs example on custom taxonomy metadata) and specifying the following in its front matter:

---
title: Classifications
outputs:
  - json
---

Not sure if this is intended behaviour.

1 Like

With the current state of your repository (at 57b96038801712cf144a0cec63d4bb205dfe52e9) I can see those index.json files you miss. Did you fix it?

/public/en/classifications/index.json

{
  "meta": {
    "copyright": "Copyright © 2019 Tulua. All rights reserved.",
    "count": 8
  },
  "data": [
    
    
    {
      "type": "classifications",
      "id": "bacteria",
      "attributes": {
        "name": "Bacteria",
        "totalDiseases": 18
      },
      "links": {
        "self": "/en/classifications/bacteria"
      }
    }
    
    ,
    {
      "type": "classifications",
      "id": "deficiency",
      "attributes": {
        "name": "Deficiency",
        "totalDiseases": 12
      },
      "links": {
        "self": "/en/classifications/deficiency"
      }
    }
    
    ,
    {
      "type": "classifications",
      "id": "environmental-factor",
      "attributes": {
        "name": "Environmental factor",
        "totalDiseases": 7
      },
      "links": {
        "self": "/en/classifications/environmental-factor"
      }
    }
    
    ,
    {
      "type": "classifications",
      "id": "fungus",
      "attributes": {
        "name": "Fungus",
        "totalDiseases": 68
      },
      "links": {
        "self": "/en/classifications/fungus"
      }
    }
    
    ,
    {
      "type": "classifications",
      "id": "insect",
      "attributes": {
        "name": "Insect",
        "totalDiseases": 78
      },
      "links": {
        "self": "/en/classifications/insect"
      }
    }
    
    ,
    {
      "type": "classifications",
      "id": "mites",
      "attributes": {
        "name": "Mites",
        "totalDiseases": 2
      },
      "links": {
        "self": "/en/classifications/mites"
      }
    }
    
    ,
    {
      "type": "classifications",
      "id": "nematode",
      "attributes": {
        "name": "Nematode",
        "totalDiseases": 2
      },
      "links": {
        "self": "/en/classifications/nematode"
      }
    }
    
    ,
    {
      "type": "classifications",
      "id": "virus",
      "attributes": {
        "name": "Virus",
        "totalDiseases": 13
      },
      "links": {
        "self": "/en/classifications/virus"
      }
    }
    
  ],
  "links": {
    "self": "/en/classifications"
  }
}

and /public/en/classifications/fungus/index.json



{
  "meta": {
    "copyright": "Copyright © 2019 Tulua. All rights reserved.",
    "totalPages": 3,
    "pageSize": 30,
    "count": 68,
    "currentPage": 1
  },
  "data": [
    
      
      {
  "type": "diseases",
  "id": "a4f855ba-ccac-4184-9ca4-76713f54e0cb",
  "attributes": {
    "title": "Allium root rot",
    "scientificName": "Sclerotium cepivorum ",
    "images": []
  },
  "links": {
    "self": "/en/diseases/sclerotium-cepivorum/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "a33b34e7-849b-4f54-bf9a-f2aceb81f757",
  "attributes": {
    "title": "Alternaria Rot",
    "scientificName": "Alternaria spp.",
    "images": []
  },
  "links": {
    "self": "/en/diseases/alternaria-spp/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "78309ff8-7b5e-4333-8bd3-b039290cba94",
  "attributes": {
    "title": "Anthracnose",
    "scientificName": "Colletotrichum sp.",
    "images": []
  },
  "links": {
    "self": "/en/diseases/colletotrichum-sp/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "000c9022-e2fa-4f3d-83d5-d9d58041cce9",
  "attributes": {
    "title": "Anthracnose of Banana",
    "scientificName": "Colletotrichum musae",
    "images": []
  },
  "links": {
    "self": "/en/diseases/colletotrichum-musae/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "58240ee3-67ac-487a-814b-18e542921429",
  "attributes": {
    "title": "Armillaria root rot",
    "scientificName": "Armillaria sp.",
    "images": []
  },
  "links": {
    "self": "/en/diseases/armillaria-sp/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "1f74b621-b29f-4777-b943-5998ba536fbd",
  "attributes": {
    "title": "Ascochyta Blight",
    "scientificName": "Ascochyta rabiei",
    "images": []
  },
  "links": {
    "self": "/en/diseases/ascochyta-rabiei/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "2309af29-37e4-4140-bc19-599ab248256d",
  "attributes": {
    "title": "Aspergillus Fruit Rot",
    "scientificName": "Aspergillus niger",
    "images": []
  },
  "links": {
    "self": "/en/diseases/aspergillus-niger/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "7c006342-878b-47b6-abca-aaf176d44079",
  "attributes": {
    "title": "Banana Freckle",
    "scientificName": "Phyllosticta maculata",
    "images": []
  },
  "links": {
    "self": "/en/diseases/phyllosticta-maculata/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "20dfe521-7ff4-4d13-a3de-e40e5f9c409c",
  "attributes": {
    "title": "Bean Anthracnose",
    "scientificName": "Colletotrichum lindemuthianum",
    "images": []
  },
  "links": {
    "self": "/en/diseases/colletotrichum-lindemuthianum/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "7a524252-bba6-417d-81e6-ce18879e288b",
  "attributes": {
    "title": "Black Sigatoka",
    "scientificName": "Mycosphaerella fijiensis",
    "images": []
  },
  "links": {
    "self": "/en/diseases/mycosphaerella-fijiensis/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "75d39561-b061-4262-9f9f-70321aebeeff",
  "attributes": {
    "title": "Black dot",
    "scientificName": "Colletotrichum coccodes ",
    "images": []
  },
  "links": {
    "self": "/en/diseases/colletotrichum-coccodes/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "84aa16dc-b9b7-488e-9dae-019a7337f9c5",
  "attributes": {
    "title": "Botrytis Neck Rot",
    "scientificName": "Botryotinia porri",
    "images": []
  },
  "links": {
    "self": "/en/diseases/botryotinia-porri/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "e4408ddc-505b-4e5a-807d-1e58899aaae9",
  "attributes": {
    "title": "Brown spot of rice",
    "scientificName": "Helminthosporium oryzae",
    "images": []
  },
  "links": {
    "self": "/en/diseases/helminthosporium-oryzae/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "c7575147-fead-4d38-a4ef-906c160e03ce",
  "attributes": {
    "title": "Cigar end rot",
    "scientificName": "Trachysphaera fructigena",
    "images": []
  },
  "links": {
    "self": "/en/diseases/trachysphaera-fructigena/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "a0306b83-8071-4781-9326-a00e8846803b",
  "attributes": {
    "title": "Citrus black spot",
    "scientificName": "Guignardia citricarpa",
    "images": []
  },
  "links": {
    "self": "/en/diseases/guignardia-citricarpa/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "cc25fd1c-14a5-49b4-a993-d6f804d3a796",
  "attributes": {
    "title": "Clubroot",
    "scientificName": "Plasmodiophora brassicae",
    "images": []
  },
  "links": {
    "self": "/en/diseases/plasmodiophora-brassicae/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "e761a1ea-e997-405a-9766-6417cd9aab76",
  "attributes": {
    "title": "Common smut",
    "scientificName": "Ustilago maydis",
    "images": []
  },
  "links": {
    "self": "/en/diseases/ustilago-maydis/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "66dfedc8-5063-4660-8831-e29c4d57b30e",
  "attributes": {
    "title": "Common spot",
    "scientificName": "Mycosphaerella fragariae",
    "images": []
  },
  "links": {
    "self": "/en/diseases/mycosphaerella-fragariae/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "d27e4bbf-bf23-4423-8370-7e41ced82c2f",
  "attributes": {
    "title": "Crazy Top",
    "scientificName": "Sclerophthora macrospora",
    "images": []
  },
  "links": {
    "self": "/en/diseases/sclerophthora-macrospora/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "225058bc-fd75-4be8-b716-7adc02a23a6d",
  "attributes": {
    "title": "Damping off",
    "scientificName": "Pythium spp.",
    "images": []
  },
  "links": {
    "self": "/en/diseases/pythium-spp/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "c14c73c5-d21d-49ad-988b-12fa99ea79a9",
  "attributes": {
    "title": "Downy mildew",
    "scientificName": "Downy mildew",
    "images": []
  },
  "links": {
    "self": "/en/diseases/downy-mildew/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "af336e27-5bab-4603-8c9c-5ea624b58d9a",
  "attributes": {
    "title": "Fungal gummosis",
    "scientificName": "Botryosphaeria dothidea",
    "images": []
  },
  "links": {
    "self": "/en/diseases/botryosphaeria-dothidea/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "355ac23c-3996-4460-91a6-e9ca454b856b",
  "attributes": {
    "title": "Fusarium Wilt",
    "scientificName": "Fusarium oxysporum",
    "images": []
  },
  "links": {
    "self": "/en/diseases/fusarium-oxysporum/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "987f7d33-2747-4ef0-a077-6aa85e402d3f",
  "attributes": {
    "title": "Ginger leaf spot",
    "scientificName": "Phyllosticta zingiberi",
    "images": []
  },
  "links": {
    "self": "/en/diseases/phyllosticta-zingiberi/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "64b5d567-89a3-4627-ad69-a6a4c5881f34",
  "attributes": {
    "title": "Grape black rot",
    "scientificName": "Guignardia bidwellii",
    "images": []
  },
  "links": {
    "self": "/en/diseases/guignardia-bidwellii/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "18b1becd-0c2f-48cf-b8ca-d6557814822f",
  "attributes": {
    "title": "Gray mold or Botrytis bunch rot",
    "scientificName": "Botrytis cinerea",
    "images": []
  },
  "links": {
    "self": "/en/diseases/botrytis-cinerea/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "b34f2bb8-5b25-45e3-9367-52e383851516",
  "attributes": {
    "title": "Greasy Spot",
    "scientificName": " Mycosphaerella citri",
    "images": []
  },
  "links": {
    "self": "/en/diseases/mycosphaerella-citri/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "5b4fb24b-0c4a-4130-804f-9795487b4ffd",
  "attributes": {
    "title": "Gummy stem blight",
    "scientificName": "Didymella bryoniae",
    "images": []
  },
  "links": {
    "self": "/en/diseases/didymella-bryoniae/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "ecf9a7ce-a461-4f2d-8b77-91aac905401f",
  "attributes": {
    "title": "Karnal bunt",
    "scientificName": "Tilletia indica",
    "images": []
  },
  "links": {
    "self": "/en/diseases/tilletia-indica/index.json"
  }
}

    
      , 
      {
  "type": "diseases",
  "id": "bb6c7b4d-682f-4840-afee-3bdc7434bbd2",
  "attributes": {
    "title": "Leaf Blight",
    "scientificName": "Alternaria cucumerina",
    "images": []
  },
  "links": {
    "self": "/en/diseases/alternaria-cucumerina/index.json"
  }
}

    
  ],
  "links": {
    "self": "/en/classifications/fungus/index.json",
    "next": "/en/classifications/fungus/page/2/index.json",
    "prev": null,
    "first": "/en/classifications/fungus/index.json",
    "last": "/en/classifications/fungus/page/3/index.json"
  }
}

It’s a temporary fix. I mentioned it in:

It’s using a custom outputFormat. I think this is hacky at best but its not the worst solution. I still think there should be a solution like what you had mentioned before (adding classifications.json to the _defaults should work IMO). Even without adding a markdown file because that would mean if I add a language I have to remember to create a markdown file for that language (thus creating lots of technical debt). Just trying to keep things simple and clean.

Any other thoughts? :smiley:

–No other thoughts… A custom taxonomy is not wrong?-- strike that. output format, not taxonomy :wink:

Can you point me to a commit after which it did not work as you described in the first post? On Github you go to your repo, then click the commits link (above the file list, little bit invisible right next to “Branches”), then click the commit hash that did not work. I can work from there.

Yeah here ya go, here is a branch that doesn’t generate the classifications:

@albanda did you try the example by @pointyfar?

Sure have. But thats for the actual terms of classifications not the actual list of terms. So it didn’t work either.

Which one are you trying to generate:

  1. /classifications/index.json (.Kind = taxonomyTerm)
  2. /classifications/foo/index.json (.Kind = taxonomy)

If #1:

  • The config on the latest branch you link to only has taxonomy configured in [outputs].
  • #1 is a taxonomyTerm. So it will default to outputting html, rss, as per docs.
  • You don’t have html layouts defined, so in trying to generate your site I get warnings:
WARN 2019/07/25 11:15:22 found no layout file for "HTML" for "taxonomyTerm": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

If #2:

  • I can see classifications/foo/index.json being generated:
public/en/classifications/bacteria/
├── index.json
└── page
    └── 1
        └── index.json
            └── index.html

1 Like

This is what we’re trying to generate. Just for you I added it to the branch but if you build it it still will have no /classifications/index.json.

There are no HTML pages in the site other than the homepage swagger doc.

As in my initial reply:

I suppose I could have been more explicit. Adding the taxonomyTerm config under [outputs] should have worked. It does not seem to, so the workaround is to add classifications/_index.md and specify outputs there; this may be a bug. You might therefore want to raise this as an issue on Github.

I have gone ahead and reported it.