There was discussion a while back about the ability to do an arbitrary exec from hugo templates, but it looks like the idea died due to security concerns.
I need to call exiftool from hugo templates (yes, the $img.Exif ability is nice, but it has a very limited set of tags available, and doesn’t provide access to basic values like the width and height of an image).
So is there any way I can invoke exiftool from inside a hugo template? I’m not building a theme, and am fine with whatever hack or workaround would allow me to do this (including invoking Go, if someone can point me in the right direction).
Thanks @bep and @yaythomas. Is there any sort of hook I could tie executing an external script into, so that every time Hugo rebuilt the site (whether in server mode or not) it would run my exiftool script and regenerate the data files?
Not unless you’re wanting to fork Hugo and pop your own insertion point in. . .
Easier is, create a file ./hugo in your project dir, give it execution rights (chmod+x, assuming you’re on a sensible O/S ) and the file would look something like this:
# do exif stuff here
exiftool -json -w exif-output.json arb-photo.jpg
mv exif-output.json data/
# call Hugo, passing input args straight through so it works like the Hugo cmd normally does
In this case you can run from your project dir:
# run your exif stuff and then Hugo
$ ./hugo server
# just run Hugo
$ hugo server