Listing data based on specific filter


I’m using a yaml data file to generate a list of my publications with meta data on a “publications” page. My data file has a “type” field where I define the type of publication, for example whether it is a journal, book chapter, etc.

Currently I’m thinking about adding a filter functionality, to make it possible for the user to filter on publication type, for example: show me only “journal” articles or “book chapters”.

I was brainstorming about what would be the best solution to create this functionality, but my solutions so far seem hard to implement or maintain in Hugo:

  1. the type field is a taxonomy, and I have separate taxonomy pages for each publication type.
    –> It doesn’t seem to be possible to populate a taxonomy based on information in the Data file?
  2. I use a querystring in the URL to pass information about which type to filter, then when I’m iterating over the data map I only show data which equals this string.
    –> It doesn’t seem to be possible to use querystrings, because Hugo uses this internally for the routing?
  3. I manually create a page for every publication type and nest it under the publications content folder, and create separate templates for each category in which the right content is being displayed from the data file
    –> This should work, but harder to maintain

Is there perhaps a solution that I didn’t consider? What would be my best option to go after?


If you create a publications content section and a content page for each publication, you can use taxonomies in the front-matter of the content pages to achieve #1. You can put all of your other metadata in the content front-matter, and the actual markdown content could be empty/ignored.

Alternative, publish the JSON in your site and use Javascript to do client-side filtering (you could get fancy with Metafizzy Isotope).

Thanks for the suggestions @moorereason, that’s really helpful.

Indeed, I realise making a content page for each publication would solve the problem. However, I deliberately chose for a data file because some of these lists are too big and it would be hard to maintain in separate files. For example if I want to do multiple edits I can simply do “find and replace” in the yaml file.

I followed your Javascript suggestion, and ended-up using MixItUp. It’s similar to Isotope, but without the masonry grid functions. By just adding the publication type as a class to the list items I can do basic filtering and sorting.