# Hashed images working in file.html but not file.md

**URL:** <https://discourse.gohugo.io/t/hashed-images-working-in-file-html-but-not-file-md/7209>\
**Category:** support\
**Created:** [June 26, 2017, 6:01pm UTC](https://discourse.gohugo.io/t/hashed-images-working-in-file-html-but-not-file-md/7209 "2017-06-26T18:01:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ecouto](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@ecouto](https://discourse.gohugo.io/u/ecouto)\
**Post date:** [June 26, 2017, 6:01pm UTC](https://discourse.gohugo.io/t/hashed-images-working-in-file-html-but-not-file-md/7209/1 "2017-06-26T18:01:41Z")

</div>

I’m using gulp with hugo, my file.html call hashed image and working fine:

`<img src="/images/{{ index .Site.Data.images.hash "profile.jpg" }}" alt="Profile">`

but in my [file.md](http://file.md) (markdown) it’s not working. =/

I tried:

`[profile]: /images/{{ index .Site.Data.images.hash "profile.jpg "profile".`

---

<div class="post-metadata">

**Author:** ![digitalcraftsman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/digitalcraftsman/32/4142_2.png) [@digitalcraftsman](https://discourse.gohugo.io/u/digitalcraftsman)\
**Post date:** [June 26, 2017, 6:17pm UTC](https://discourse.gohugo.io/t/hashed-images-working-in-file-html-but-not-file-md/7209/2 "2017-06-26T18:17:20Z")

</div>

Content files aren’t templates. Hence they won’t be parsed. Have a look at [shortcodes](https://gohugo.io/extras/shortcodes#shortcodes-with-markdown) instead.

---

<div class="post-metadata">

**Author:** ![ecouto](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@ecouto](https://discourse.gohugo.io/u/ecouto)\
**Post date:** [June 26, 2017, 7:44pm UTC](https://discourse.gohugo.io/t/hashed-images-working-in-file-html-but-not-file-md/7209/3 "2017-06-26T19:44:38Z")

</div>

I put in my [file.md](http://file.md)

`{{<img src="/images/{{ index .Site.Data.images.hash "profile.jpg" }}" title="Profile">}}`

I created the file _/layouts/shortcodes/img.html_

```
<!-- image -->
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
    {{ with .Get "link"}}<a href="{{.}}">{{ end }}
        <img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}"{{ end }} />
    {{ if .Get "link"}}</a>{{ end }}
    {{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
    <figcaption>{{ if isset .Params "title" }}
        <h4>{{ .Get "title" }}</h4>{{ end }}
        {{ if or (.Get "caption") (.Get "attr")}}<p>
        {{ .Get "caption" }}
        {{ with .Get "attrlink"}}<a href="{{.}}"> {{ end }}
            {{ .Get "attr" }}
        {{ if .Get "attrlink"}}</a> {{ end }}
        </p> {{ end }}
    </figcaption>
    {{ end }}
</figure>
<!-- image -->

```

**but I get it on inspect:**

`<img src="/images/%7b%7b%20index%20.Site.Data.images.hash%20">`

Error to load image.

---

<div class="post-metadata">

**Author:** ![digitalcraftsman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/digitalcraftsman/32/4142_2.png) [@digitalcraftsman](https://discourse.gohugo.io/u/digitalcraftsman)\
**Post date:** [June 26, 2017, 8:00pm UTC](https://discourse.gohugo.io/t/hashed-images-working-in-file-html-but-not-file-md/7209/4 "2017-06-26T20:00:22Z")

</div>

Have a look at the [`safeURL`](https://gohugo.io/templates/functions/#safeURL) template function to mark your generated urls as save.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [June 26, 2017, 9:19pm UTC](https://discourse.gohugo.io/t/hashed-images-working-in-file-html-but-not-file-md/7209/5 "2017-06-26T21:19:03Z")

</div>

> [@ecouto](#):
>
> \<img src=“/images/%7b%7b%20index%20.Site.Data.images.hash%20”\>

Also if `safeURL` doesn’t work you might try using this:

> `<img src="{{ .Get "src" | safeHTMLAttr }}"`

More info over here: [Functions | Hugo](https://gohugo.io/templates/functions#safehtmlattr)

---

<div class="post-metadata">

**Author:** ![ecouto](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@ecouto](https://discourse.gohugo.io/u/ecouto)\
**Post date:** [June 26, 2017, 9:28pm UTC](https://discourse.gohugo.io/t/hashed-images-working-in-file-html-but-not-file-md/7209/6 "2017-06-26T21:28:40Z")

</div>

It’s not working too =/

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [June 26, 2017, 9:46pm UTC](https://discourse.gohugo.io/t/hashed-images-working-in-file-html-but-not-file-md/7209/7 "2017-06-26T21:46:57Z")

</div>

Of course it doesn’t.

It’s not just the broken URL output.

You’re also calling the img Parameter the wrong way.

The Param Method should be inside your img.html not in the content file.

See here for proper use: [https://gohugo.io/templates/variables#param-method](https://gohugo.io/templates/variables#param-method)

Read about Shortcodes a bit more. Also search the forum. There are plenty of examples about your issue.

---

<div class="post-metadata">

**Author:** ![ecouto](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@ecouto](https://discourse.gohugo.io/u/ecouto)\
**Post date:** [June 26, 2017, 11:21pm UTC](https://discourse.gohugo.io/t/hashed-images-working-in-file-html-but-not-file-md/7209/8 "2017-06-26T23:21:13Z")

</div>

@alexandros May you give me a bit more tips about this issue?

It’s so dificult for me, maybe could you tell me what the correct term I have to search in forum?

I’ll read a bit more about shortcodes too.

Sorry but I tried to find something but I did not find the same problem.

Thank You for help me.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [June 27, 2017, 4:58am UTC](https://discourse.gohugo.io/t/hashed-images-working-in-file-html-but-not-file-md/7209/9 "2017-06-27T04:58:44Z")

</div>

How have you specified the image that you’re trying to call with `.Site.Data.images.hash`?

Is it specified in `config.toml` or in the front matter of a content file? Will this image be used site wide? Or are you calling different images with the same parameter under different sections and/or content files?

---

<div class="post-metadata">

**Author:** ![ecouto](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@ecouto](https://discourse.gohugo.io/u/ecouto)\
**Post date:** [June 27, 2017, 7:01pm UTC](https://discourse.gohugo.io/t/hashed-images-working-in-file-html-but-not-file-md/7209/10 "2017-06-27T19:01:29Z")

</div>

> [@alexandros](#):
>
> How have you specified the image that you’re trying to call with .Site.Data.images.hash?
> 
> I’m using gulp whit hugo, [http://danbahrami.io/articles/building-a-production-website-with-hugo-and-gulp-js/](http://danbahrami.io/articles/building-a-production-website-with-hugo-and-gulp-js/).\*\*
> 
> Is it specified in config.toml or in the front matter of a content file? Will this image be used site wide? Or are you calling different images with the same parameter under different sections and/or content files?
> 
> I’ll call different images with the same parameter different sections and/or content files\*\*

Is it specified in config.toml or in the front matter of a content file?  
Not

I’m using gulp whit hugo, [http://danbahrami.io/articles/building-a-production-website-with-hugo-and-gulp-js/](http://danbahrami.io/articles/building-a-production-website-with-hugo-and-gulp-js/).\*\*

I’ll call different images with the same parameter different sections and/or content files\*\*
