I’m trying to figure out how to count the number of unique companies I have in my Content folder. The front matter for each post is as follows:
company = "Acme Inc"
date = "2017-10-01T01:08:19+02:00"
product = "Apples"
company = "Acme Inc"
date = "2017-10-01T01:08:19+02:00"
product = "Pears"
company = "Dumbo Inc"
date = "2017-10-01T01:08:19+02:00"
product = "Oranges"
Thanks for helping out. I’ve tried your code, but I receive the following error message:
Error while rendering "home": template: index.html:53:13: executing "index.html" at <index .Site.RegularP...>: error callingindex: cannot index slice/array with nil
To activate the taxonomy enough to add two lines to the config.yaml.
taxonomies:
company: ""
As far as I remember, if you add a taxonomy with an empty value, it will become available as $.Site.Taxonomies.company, but Hugo will not generate an unnecessary folder for it.
$.Site.Taxonomies.company does not work. I’m using toml, but that shouldn’t matter. The taxonomy is an empty value. I’ve tried to get this to work and show all company names but it just returns 0 so of course the counter doesn’t work either.