Generate HTML from image metadata?

If I want to create a photoblog it would be handy if I could generate HTML pages from image files containting XMP metadata (like Title and DateTimeOriginal). Creating markdown or HTML pages to use as input seems like an unnecessary step when the data is already in the image files.

Is it possible?

Hugo can read EXIF, but not XMP or IPTC. You could use something like exiftool before each build to copy from one field to another[1] (e.g., some XMP field to the EXIF ImageDescription field). Your photo management app may do that already, or may be configurable.

Assuming the data you want is available in the EXIF tags, then yes, you can generate pages from this data. There are a couple of approaches.

  1. exiftool can do this recursively over a directory structure with a single command, and it is very fast. ↩︎

Thanks! Yes, I could house the metadata in Exif. What approaches are there? Having trouble finding any examples that does this.


I wanted to use IPTC fields instead of Exif ones.
Before using hugo server I use exiftool in order to generate Json files which are read by the templates :using getJSon.

see hugo_site/themes/welsh/layouts/portraits/portfolio.html · main · Fred GALLOIS / genealogie-docs · GitLab

That will be deprecated in the next release. use resources.GetRemote with transform.Unmarshal instead.

The “prebuild” approach allows you to paginate results, assign taxonomy terms, etc:

If you don’t care about pagination or adding taxonomy terms, you could use resources.ExecuteAsTemplate then Publish.

Neither approach is suitable for new or casual users; you need to know what you’re doing.

If you can’t stuff what you want into EXIF fields, use @Welsh’s suggestion… works great.

Thanks I will change.

I don’t think I would need pagination etc.

Exif would work great. Exif.Photo.ImageTitle and Exif.Image.ImageDescription would probably be enough.

To be honest, I don’t know if that’s me, but I’ll look into resources.ExecuteAsTemplate and Publish.



See the / after the word string? That means “avoid”.

Hugo uses rwcarlsen/goexif to read EXIF data, and it can’t read the Title.

ImageDescription works fine, as does ImageUniqueID, but I would reserve the latter for a unique identifier (e.g., the signature generated by ImageMagick’s identify -verbose -format %# a.jpg).

You could also hijack Artist, Make, Model, or Software. Some site authors use the file name to generate the alt attribute; I suppose you could do the same with title.

Thanks! This whole ordeal turned out to be a bit too complicated for my personal use. Perhaps I’ll give it a try if I’m able to find a code example.