Command line way to get/set front matter variable?

Does hugo have any command line tools or an api to extract or get front matter data? (Or set data, for that matter) For example, if I have pages with an customer_id variable, is there some way I can get a list of all the customer_id’s from all pages from the command line?

If not, does anyone have an idea for an easy workaround to get this data?

More specifically, I’d like to be able to do something like:

for page in pages
 id = page.customer_id
 result = call_api(customer_id)
 page.other_variable = result

This would be in a job that might be called once a week

Hugo doesn’t but a python script like what you have coded there would work, combined with providing/finding a list of files, the keys to parse and refill.

Ok may do that, I just found GitHub - eyeseast/python-frontmatter: Parse and manage posts with YAML (or other) frontmatter which might make this easy

1 Like

I would take a look at yq: