# How to show images on post pages if they're located in the assets folder?

**URL:** <https://discourse.gohugo.io/t/how-to-show-images-on-post-pages-if-theyre-located-in-the-assets-folder/34276>\
**Category:** support\
**Created:** [August 15, 2021, 9:20pm UTC](https://discourse.gohugo.io/t/how-to-show-images-on-post-pages-if-theyre-located-in-the-assets-folder/34276 "2021-08-15T21:20:12Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![solopx](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/solopx/32/8218_2.png) [@solopx](https://discourse.gohugo.io/u/solopx)\
**Post date:** [August 28, 2021, 5:21am UTC](https://discourse.gohugo.io/t/how-to-show-images-on-post-pages-if-theyre-located-in-the-assets-folder/34276/14 "2021-08-28T05:21:21Z")

</div>

Hi guys,

To be able to access images as resources, I’m doing this:

1. add the images in “content/media”
2. add in “content/media” also \_index.md as below:

content/media/\_index.md

```auto
+++
headless= true
title= "Media"
+++

```

1. In the page where you need them ex:

content/about.md

```auto
---
date: "..."
title: "about"
featuredImage: "media/sample-image.jpg"
---

# About

```

1. you can now access them in templates:

```auto
{{ $img := .Params.featuredImage }}
{{ $alt := .Title }}

{{ range wit $.Site.Pages }}
    {{ with .Resources.Match $sourceImage }}
        {{ range . }}
            {{ $imageXL := .Resize "..." }}
            {{ $imageL := .Resize "..." }}
            {{ $imageM := .Resize "..." }}
            <picture>
                <source data-srcset='{{ $imageM.RelPermalink }}' type='image/jpg' media='(max-width: 500px)'>
                <source data-srcset='{{ $imageM.RelPermalink }}' type='image/jpg' media='(max-width: 900px)'>
                <source data-srcset='{{ $imageXL.RelPermalink }}' type='image/jpg' media='(min-width: 901px)'>
                <img loading="lazy" data-src='{{ $imageXL.RelPermalink }}' class='lazyload img-fluid' alt='{{ $alt }}' />
            </picture>
            <noscript>
                <img src="{{ $imageXL.RelPermalink }}" alt="{{ $alt }}" />
            </noscript>
        {{ end }}
    {{ end }}
{{ end }}

```

Hope the above is helping you.

---

_[View the full topic](https://discourse.gohugo.io/t/how-to-show-images-on-post-pages-if-theyre-located-in-the-assets-folder/34276)._
