Output page bundle images to a separate folder

I am migrating a website to use page bundles so I can use image pipelines, and I’m struggling with how the content is organized in the public folder.

In the content folder, I have page bundles that look like:

  • content/posts/2021-03-11-title/ which contain things like:
    • content/posts/2021-03-11-title/index.md → the post
    • content/posts/2021-03-11-title/images/foo.png → various images

I am using image pipelines to create multiple smaller versions of those images.

The problem is that after migrating to this system, all images (minified and not) are kept in the page bundle. So in the public folder I have images all over the place, for example:

  • public/2021/03/11/title/foo.png
  • public/2021/03/11/title/foo-xxxxx-yyy.jpg (for minified images

I need all images to be put in a separate folder, such as public/images/. It’s fine if they’re in subfolders there, but I need them to be in a separate path so I can more easily manage them through the CDN.

I have been looking at the docs but I can’t seem to find a solution to this.

Any suggestion?

It is not possible to do what you ask with Page Bundles.

Your only option is to store those assets in your desired folder under the assetDir and fetch them in your content files -possibly through a Shortcode or a Markdown Render Hook- with the method resources.Get.

Thanks for helping. I am already using a shortcode so that would work.

However, I’ve been trying for about one hour to get resources.Get to work, but I can’t load any asset from my assetDir (aka the asset/ folder).

Would you have an example of how that would work?

It is as simple as resources.Get "folder/some.jpg"

Do not include the assetDir name in the PATH of the above method.