1,784,655 bytes to 36,616, by moving one file
Page bundles make an image a page resource, which is what unlocks the processing pipeline.
Evidence
- The desktop screenshot is 6664 × 2168 and 1.74 MB.
- It was being served at full size into a column about 672px wide.
- Every byte past that width was downloaded and thrown away.
The fix
-
What surprised me is that the fix isn’t a setting. It’s where the file lives.
-
From this:
content/posts/first-try.md assets/my-virtual-desktop-setup.png -
to this:
content/posts/first-try/index.md content/posts/first-try/my-virtual-desktop-setup.png -
That’s a page bundle, and inside one the image stops being a loose asset and becomes a page resource — reachable via
.Page.Resources.Get, carrying its own front matter for alt text and caption and credit, and eligible for.Resize. -
The theme’s figure partial then does what it already does for its own images: anything over 1400px wide gets resized and converted to WebP at q82.
1,784,655 bytes → 36,616 bytes -
Forty-eight times smaller.
-
I compared them at display size and can’t tell them apart.
The rule underneath
- A file’s location determines what Hugo is permitted to do with it.
static/is frozen.assets/is processable.- A page bundle is processable and carries metadata.
Put images in bundles.