# Fingerprinting image assets with pure markdown templates?

**URL:** <https://discourse.gohugo.io/t/fingerprinting-image-assets-with-pure-markdown-templates/27622>\
**Category:** support\
**Created:** [August 16, 2020, 8:53pm UTC](https://discourse.gohugo.io/t/fingerprinting-image-assets-with-pure-markdown-templates/27622 "2020-08-16T20:53:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![searls](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/searls/32/12161_2.png) [@searls](https://discourse.gohugo.io/u/searls)\
**Post date:** [August 16, 2020, 8:53pm UTC](https://discourse.gohugo.io/t/fingerprinting-image-assets-with-pure-markdown-templates/27622/1 "2020-08-16T20:53:30Z")

</div>

Hello! Long-time Hugo user and generally Big Fan™, but first time posting to the forum.

I have a site that is being maintained with [Netlify CMS](https://www.netlifycms.org) (both for uploading images and for editing markdown with a WYSWIG), so that’s a constraint I’m under.

One of the things I’d like is fingerprinting images that are defined in markdown content pages (e.g. `![](/some/path/test-image.jpg)`, where the image file resides in `assets/some/path/test-image.jpg`). I need to specify the images this way (as opposed to with a shortcode), because WYSIWIG markdown editors can help users upload and set images in markdown, but don’t know anything about Hugo specific templating.

I expected this to work with Hugo scanning markdown for image syntax and then doing a `Resources.Get` under the covers such that the file reference is detected at build-time and a fingerprint is automatically added to the asset and the URL updated in the resulting HTML.

But as far as I can tell is that none of this happens, and if you want fingerprints on images referenced in markdown posts, you **must** break out of pure markdown and use a shortcode.

Am I way off base here or is this a thing Hugo doesn’t do?

---

<div class="post-metadata">

**Author:** ![sephore](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sephore/32/11673_2.png) [@sephore](https://discourse.gohugo.io/u/sephore)\
**Post date:** [August 16, 2020, 9:18pm UTC](https://discourse.gohugo.io/t/fingerprinting-image-assets-with-pure-markdown-templates/27622/2 "2020-08-16T21:18:01Z")

</div>

I don’t know much about Netlify CMS, but couldn’t [markdown render hooks](https://gohugo.io/getting-started/configuration-markup#markdown-render-hooks) be an option?

---

<div class="post-metadata">

**Author:** ![searls](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/searls/32/12161_2.png) [@searls](https://discourse.gohugo.io/u/searls)\
**Post date:** [August 16, 2020, 9:39pm UTC](https://discourse.gohugo.io/t/fingerprinting-image-assets-with-pure-markdown-templates/27622/3 "2020-08-16T21:39:45Z")

</div>

Oh yeah? I read the docs but I’m still a little fuzzy on where to start here — does anyone have an example of this used on images? I suspect most sites would have pretty similar operations

---

<div class="post-metadata">

**Author:** ![sephore](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sephore/32/11673_2.png) [@sephore](https://discourse.gohugo.io/u/sephore)\
**Post date:** [August 16, 2020, 10:04pm UTC](https://discourse.gohugo.io/t/fingerprinting-image-assets-with-pure-markdown-templates/27622/4 "2020-08-16T22:04:10Z")

</div>

Uh? There’s an example of `render-image.html` being used. You would only need to pipe the `.Destination`. Something like:

```auto
{{ $title := .Title }}
{{ $altTxt := .Text }}

{{ with resources.GetMatch .Destination }}
  <img src="{{ (. | fingerprint).Permalink }}" alt="{{ $altTxt }}" {{ with $title }} title="{{ . }}"{{ end }} />
{{ end }}

```

Can’t really give you an exact answer since I don’t know your project structure.

In this example, `![Some image.](img/some-image.jpg)` is picking the `assets/img/some-image.jpg`, processing and rendering the image file with the fingerprint.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [September 14, 2020, 10:10pm UTC](https://discourse.gohugo.io/t/fingerprinting-image-assets-with-pure-markdown-templates/27622/5 "2020-09-14T22:10:25Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
