Reuse images in page bundles in homepage _index.md from a shortcode

With a content layout like:

    /content
     _index.md
     pagedir/index.md
                 image.jpg

Refrencing an image in a shortcode works nicely in pagedir/index.md but how can I reference image.jpg when calling a shortcode in _index.md? Is it possible yet?

I feel like I should just be able to do this in the shortcode
{{ $src := .Resources.Match (printf "*%s*" (.Get "src")) }}
And in home page _index.md do:
{{< figure-imgsrc src=“pagedir/image.jpg” >}}
But I get the impression from an hour of reading that it’s not currently possible.

Failing that how can I keep several images available for the homepage _index.md without just messily dropping them into content/ or treating them as assets? (They really are just home page content.)
I want to process the images in a shortcode too.

Hi!

Yes, this is the case for a branch bundle:

Where can the Resources live? Only in the directory level of the branch bundle directory i.e. the directory containing the _index.md.

You just need to copy your image to /content/.

Had tried that, it didn’t work - I’ll take a closer look at my shortcode, try the built in one with that path.

Still think dropping a bunch of images in at the top level of content feels messy :slight_smile:

Turns out I had a curly quote instead of a straight quote at the end of src declaration in _index.md :sob:

All solved. Marked your answer as a solution anyway @Grob since it is correct :slight_smile:

1 Like