After changes in Hugo 0.123 moving forward I finally decided to embrace a page bundles to help me better manage resources that belong to selected pages. When started reading about Page Bundles vs Leaf Bundle and try on my own I faced some confusion that would like to get help to understand please.
Let me start with introduction:
content/
├── about.md
├── images/
│ ├── 2024/
│ │ ├── 01/
│ │ │ ├── this-image-1.jpg
│ │ │ ├── other-image.jpg
│ │ │ ├── fancy-picture.jpg
Part of front matter
---
title: 'About Us'
url: '/about/'
featuredImage: "/images/2024/01/this-image-1.jpg"
---
Text
![the other image](/images/2024/01/other-image.jpg)
Some more text
![the fancy picture of something](/images/2024/01/fancy-picture.jpg)
To make easier to manage resources I moved this into page bundle
content/
|── about/
| |── index.md
| |── this-image-1.jpg
| |── other-image.jpg
| |── fancy-picture.jpg
So the markdown become much simpler
---
title: 'About Us'
url: '/about/'
featuredImage: "this-image-1.jpg"
---
Text
![the other image](other-image.jpg)
Some more text
![the fancy picture of something](fancy-picture.jpg)
ps. I understand that I may not need
url
in such instance, but want to keep it for simplicifaction.
The render-image.html
got this part in:
{{ $image := "" }}
{{ if .Page.BundleType }}
{{ $image = .Page.Resources.GetMatch .Destination }}
{{ else }}
{{ $image = resources.Get .Destination }}
{{ end }}
Which working nicely if page is not a page bundle, to catch resources from a path like /images/2024/01...
and when page is a page bundle to catch resources directly.
Now, I would like to add section to about, but keeping the main page as well.
So, there will be /about/
but later I want to add /about/associations/
As I understand, I cannot put page bundle inside page bundle, as this is not working.
I cannot change /about/index.md
to /about/_index.md
as in that case page /about/
is not rendering even that when there is /about/associations/index.md
and is rendering under /about/associations/
. Thats because _index.md
is used for something else.
Whats the approach to unbundle /about/
part allowing to have sub folders as a page bundles, but without braking images and need to change from just (other-image.jpg)
back to (/about/other-image.jpg)
. Assume that /about/index.md
will need to be /about/about.md
to work.
Is there any ay to approach this correctly?
Maybe its just render-image.html
that need to be adjusted?
I am thinking that incorporating, in a middle
resources.GetMatch
(orresources.Match
?) for non-BundleType will allow mixed non-bundle (if link is relative or absolute) and bundle approach without need to rewrite path to files?
Please help me understand this