Shortcode not loading page resources

I’m trying to create a shortcode that ranges through any images from the page resources and displays them. My code is below:

<div class="gallery">
    <ul>
        {{ range .Page.Resources.Match "**.png" }}
        <li>
            <a href="{{ .RelPermalink }}">
                <img src="{{ .RelPermalink }}">
            </a>
        </li>
        {{ end }}
    </ul>
</div>

I include this into _index.md like so:

{{< gallery >}}

Within the frontmatter of _index.md I have the following resources defined:

[[resources]]
    src = "featured-work/1.png"
    title = ""

[[resources]]
    src = "featured-work/2.png"
    title = ""

[[resources]]
    src = "featured-work/3.png"
    title = ""

Within content I have a featured-work directory that contains the images.

The gallery code is being loaded into the html source but the list is empty.

Any idea what I’m doing wrong?

A little hard to say without the full context, but is your content a bundle, e.g. index.md?

The content is in an _index.md at the root of /content. This is for the homepage. A branch bundle I believe.

OK, then I see. We may lift this limitation – but currently branch bundles is 1 level only. So, if you move your images from featured-work and up to the root, it will work.

Perfect @bep! Works. I was scratching my head for a while.