# Accessing page resources by name?

**URL:** <https://discourse.gohugo.io/t/accessing-page-resources-by-name/15228>\
**Category:** support\
**Created:** [November 10, 2018, 9:16pm UTC](https://discourse.gohugo.io/t/accessing-page-resources-by-name/15228 "2018-11-10T21:16:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JamesTheHacker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jamesthehacker/32/6919_2.png) [@JamesTheHacker](https://discourse.gohugo.io/u/JamesTheHacker)\
**Post date:** [November 10, 2018, 9:16pm UTC](https://discourse.gohugo.io/t/accessing-page-resources-by-name/15228/1 "2018-11-10T21:16:51Z")

</div>

I have some images in a page bundle. What I would like to do is refer to these image resources by their name so I can `range` through my array of objects and get the correct image. Here’s my front matter:

```
---
title: "We're Legit"

resources:
  - src: "images/certas-logo.svg"
    title: "Certas Logo"
    name: certas-logo
  = src: "images/trading-standards-logo.svg"
    title: "Trading Standards Logo",
    name: trading-standards-logo
  - src: "images/no-rouge-traders-here-logo.png"
    title: "No Rouge Traders Here Logo"
    name: no-rouge-traders-here-logo
  - src: "images/home-pro-logo.webp"
    title: "Home Pro Logo"
    name: home-pro-logo

accreditations: [
  {
    title: Certas,
    url: https://www.certasenergy.co.uk,
    number: "#",
    image: certas-logo
  },
  {
    title: Trading Standards,
    url: https://www.tradingstandards.uk,
    number: "#",
    image: trading-standards-logo
  },
  {
    title: No Rouge Traders Here,
    url: https://www.noroguetradershere.com,
    number: N/A,
    image: no-rouge-traders-here-logo
  },
  {
    title: Home Pro,
    url: https://www.homepro.com,
    number: "#",
    image: home-pro-logo
  }
]
---

Testing

```

As you can see I have a list of accreditations. I need to load the image resource for each one. I have attempted like so but I get `unknown` in the `src` attribute.

```
{{ with .Site.GetPage "accreditations/index.md" }}
<div class="uk-section">
  <h2>{{ .Title }}</h2>
  {{ with .Content }}
  <p class="summary">{{- . -}}</p>
  {{ end }}

  <ul class="uk-grid-small uk-child-width-expand@s uk-text-center" uk-grid>
    {{ range .Params.accreditations }}
    <li>
      {{ $img := .Resources.Match (.image) }}
      <img src="{{ $img.RelPermalink }}">
      <h3>{{ .title }}</h3>
      <p>{{ .number }}</p>
    </li>
    {{ end }}
  </ul>
</div>
{{ end }}
```

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [November 10, 2018, 9:21pm UTC](https://discourse.gohugo.io/t/accessing-page-resources-by-name/15228/2 "2018-11-10T21:21:50Z")

</div>

> [@JamesTheHacker](#):
>
> {{ $img := .Resources.Match (.image) }}

There are several good resources about the “context” or “the mystery of the dot” out there, but the short story here is that “.Resources” will not work here.

If you do:

```bash
{{ with .Site.GetPage "accreditations/index.md" }}
$resources := .Resources
...

 {{ $img := $resources.Match (.image) }}

```

---

<div class="post-metadata">

**Author:** ![JamesTheHacker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jamesthehacker/32/6919_2.png) [@JamesTheHacker](https://discourse.gohugo.io/u/JamesTheHacker)\
**Post date:** [November 10, 2018, 9:23pm UTC](https://discourse.gohugo.io/t/accessing-page-resources-by-name/15228/3 "2018-11-10T21:23:54Z")

</div>

Ooooh yes because the `.` is the `range` context. I totally missed that. I need to put in some time to learn Go properly.

For anyone who has a similar problem here’s my complete working solution:

```
{{ with .Site.GetPage "accreditations/index.md" }}
{{ $resources := .Resources }}
<div class="uk-section">
  <h2>{{ .Title }}</h2>
  {{ with .Content }}
  <p class="summary">{{- . -}}</p>
  {{ end }}

  <ul class="uk-grid-small uk-child-width-expand@s uk-text-center" uk-grid>
    {{ range .Params.accreditations }}
    <li>
      {{ with $resources.GetMatch (.image) }}
      <img src="{{ .Permalink }}">
      {{ end }}
      <h3>{{ .title }}</h3>
      <p>{{ .number }}</p>
    </li>
    {{ end }}
  </ul>
</div>
{{ end }}
```
