I’m not even sure whether it’s an issue or not, but assuming Hugo claims to be super-fast, I’m now a bit curious because… my blog draft generation takes at least 2 minutes and at least few times more than that with responsive images generation (Responsive and optimized images with Hugo | BryceWray.com)
But even leaving responsive images aside (wrap around with {{ if not hugo.IsDevelopment }}
):
- Generate site without the post.
Total in 24404 ms
→ seems a bit slow, but might be fine for one-time job
| RU | EN
-------------------+-----+-----
Pages | 122 | 41
Paginator pages | 11 | 0
Non-page files | 52 | 23
Static files | 17 | 17
Processed images | 185 | 0
Aliases | 41 | 16
Cleaned | 0 | 0
- Add the post without any images in it, run
hugo build
again (on top of previously created dir) →Total in 1051 ms
, seems ok - Add photos. I have 91 image file for the post, totaling 412 Mb, so average 4Mb per photo. → and now watch the magic…
INFO build: step render substep pages site ru outputFormat html duration 1m44.5801053s
INFO build: step render substep pages site ru outputFormat json duration 155.1245ms
INFO build: step render substep pages site ru outputFormat rss duration 25.0697ms
INFO build: step render substep pages site en outputFormat html duration 99.3612ms
INFO build: step render substep pages site en outputFormat json duration 138.8415ms
INFO build: step render substep pages site en outputFormat rss duration 2.9989ms
INFO build: step render pages 173 content 120 duration 1m45.0075453s
INFO build: step render deferred count 0 duration 0s
INFO build: step postProcess duration 0s
INFO build: duration 1m45.2375945s
| RU | EN
-------------------+-----+-----
Pages | 123 | 41
Paginator pages | 11 | 0
Non-page files | 147 | 23
Static files | 17 | 17
Processed images | 457 | 0
Aliases | 41 | 16
Cleaned | 0 | 0
Total in 105280 ms
Almost 2 minutes. For just one post. For the sake of statistics, if I remove both public
and resources/_gen
and run the full generation again, it now takes… 125 seconds. Which is in line with what I saw earlier - basically single the post adds 1.5 minutes of pure generation time.
And for the curious reader - if I now enable responsive images generation and run the build again, then (even without clearing build directories) hugo build
first timed out with 10 minutes and then finished on the second run with 16 seconds. So, 10 minutes basically for almost a single post.
My img
shortcode (which I use for every image and what I believe takes the most time) does a few things:
- Finds image using
$.Page.Resources.GetMatch
- Renames it to some human-readable name using
resources.Copy $newName
- Resizes once using
$resource.Resize "600x"
- Gets md5 hash of the path.
- Extracts EXIF tags using
with $resource.Exif
- Resizes again using
$imgRsc.Process (print "resize 640x jpg box")
(yes-yes this is probably redundant, some artifact left after merging my initialimg
with responsive generation code from the linked page above, but if I enable responsive image generation, I’ll have 6 more resizes anyway, so it shouldn’t significantly matter)
That’s all of potentially resourse-consuming code I see in my img
.
I think in the first place it’s myself doing something wrong. Am I not supposed to use original images in my page resources? Is there some kind of recommendation which size should the images be to be processed faster by Hugo?
But in the second place, I honestly don’t think 100 images is a lot. I’m running it on my Windows full tower PC, on SSD (can provide full specs if needed), why is single post (I’m going to have at least a few dozens of similar sized posts) generation takes minutes on full PC? I have my mini-blog with 20 posts, each is some long trip/travel report. This particular post was composed after 4-days cycling trip in Europe, and I haven’t even migrated to Hugo my posts about 2-3 weeks vacations (which would easily have 10-15+ photos per day → 200 photos at least).
The images I put to Hugo are (mostly) JPGs generated from RAW via Lightroom and resized during export to 1620 width and ~1Mb, but for some posts (like the one in subj) also JPGs from my phone camera (Pixel 8, 4000*3000 res jpg as is, 3-11 Mb)