Can /content/_index.md
contain resources?
I ask because I have multiple page bundles that are working fine with resources. I have /content/window-cleaning-services/images
, and /content/window-cleaning-services/index.md
that defines the resources in the frontmatter along with additional params such as alt tags etc. All that works fine, I can query the resources etc.
But when I try to do the same from /content/_index.md
non of the images load.
Here I have a shortcode called JobGallery
. When used it loads all .png
images from any directory in t he bundle that contains the word jobs
. In my case, for this project, such directories will only be used to display images of my clients work:
<section class="gallery">
<div class="container">
<h2 class="heading-2">{{ .Get "title" }}</h2>
<p class="lead-2">{{ .Get "description" }}</p>
{{ with .Page.Resources.Match "*jobs*/*.png" }}
<ul class="row">
{{ range . }}
<li class="col-12 col-md-4 col-lg-3 gallery-item">
<a class="lightbox" href="{{ .Permalink }}">
<img src="{{ .Permalink }}" width="100%" title="{{ .Title }}" alt="{{ .Params.alt }}">
</a>
</li>
{{ end }}
</ul>
{{ end }}
</div>
</section>
In my /content/_index.md
I define resources like so. Defining resources like this is an absolute pain but as I require extra data for the images I can’t see any other way to do this:
++++
[[resources]]
src="recent-jobs-in-birmingham/large-window-cleaning.png"
title="Title here"
[resources.params]
alt="Alt here"
....
+++
{{< JobGallery
title="Our Recent Work"
description="A description for lead text"
>}}
I have the images for the index page stored in /content/recent-jobs-in-birmingham/
.
This doesn’t work on the _index.md
page but works everywhere else on the site.