Slow Build Performance or Bad coding?

Hello Hugo community,

I just ported a wordpress site of 2500 pages to Hugo CMS .

Here is the finished site – https://www.wktvusa.com/ (custom style based on bootstrap 4) and here is all the code https://github.com/fieldingtron/wktvusa

Im getting what I think are slow build times like 10 minutes from build to deploy via netlify

here are my hugo – templateMetrics

Would anyone have an idea where I am not coding correctly ? I have tried to use Cached Partials but without much effect

Template Metrics:

     cumulative       average       maximum
       duration      duration      duration  count  template
     ----------      --------      --------  -----  --------
  11m57.399812s  340.807511ms     2.279229s   2105  partials/imagecode.html
  11m34.192993s  341.630409ms     930.246ms   2032  news/single.html
     14.907453s    14.907453s    14.907453s      1  videos/list.html
      8.762261s     8.762261s     8.762261s      1  index.html
      5.563377s    4.985104ms      42.597ms   1116  _default/list.html
      2.475468s     2.475468s     2.475468s      1  partials/slider.html
      1.462277s  182.784625ms     366.068ms      8  mainpages/general.html
      1.452405s  132.036818ms     363.886ms     11  partials/main-sidebar.html
      1.423966s    355.9915ms     356.772ms      4  partials/ads.html
      1.363335s   48.690535ms     164.934ms     28  _internal/_default/rss.xml
      345.432ms     640.875µs      32.888ms    539  videos/single.html
      169.504ms     169.504ms     169.504ms      1  _internal/_default/sitemap.xml
      148.224ms     148.224ms     148.224ms      1  mainpages/sitemap.html
       98.904ms      26.723µs         841µs   3701  partials/site/meta.html
       25.799ms      25.799ms      25.799ms      1  news/list.html
       13.954ms      13.954ms      13.954ms      1  index.redirects
          544µs         544µs         544µs      1  section/organization.html
          432µs         432µs         432µs      1  404.html
          200µs         100µs         121µs      2  partials/site/scripts.html
          177µs        88.5µs         150µs      2  partials/site/footer.html
          136µs          68µs         132µs      2  partials/modal.html
          101µs        50.5µs          87µs      2  partials/site/navbar.html
           83µs          83µs          83µs      1  shortcodes/contactus.html
           70µs          70µs          70µs      1  partials/site/styles.html
            5µs           5µs           5µs      1  index.headers


                   |  EN
+------------------+------+
  Pages            | 2639
  Paginator pages  | 1092
  Non-page files   | 2557
  Static files     |   76
  Processed images | 2050
  Aliases          |   24
  Sitemaps         |    1
  Cleaned          |    0

Total in 218890 ms

and here is the stepAnalysis

hugo --stepAnalysis
Building sites … initialize:
        86.273ms (88.992ms)        12.25 MB     218011 Allocs
load data:
        433µs (89.657ms)            0.02 MB     123 Allocs
load i18n:
        2µs (89.829ms)      0.00 MB     0 Allocs
read and convert pages from source:
        2.17666s (2.266798s)      199.16 MB     1519739 Allocs
build Site meta:
        23.049ms (2.290127s)        2.45 MB     57831 Allocs
prepare pages:
        52.539ms (2.342931s)       11.92 MB     111596 Allocs
render and write pages:
        1m8.278856s (1m10.622062s)        702.63 MB     14422787 Allocs
render and write Sitemap:
        194.169ms (1m10.816533s)           13.52 MB     240487 Allocs
render and write robots.txt:
        19µs (1m10.816777s)         0.00 MB     9 Allocs
render and write 404:
        16.993ms (1m10.834056s)     0.04 MB     467 Allocs
render and write pages:
        869.596ms (1m11.703902s)          115.53 MB     1566845 Allocs
render and write pages:
        4.698ms (1m11.708947s)      0.06 MB     764 Allocs
render and write pages:
        23.641ms (1m11.734848s)     0.11 MB     6008 Allocs

                   |  EN
+------------------+------+
  Pages            | 2639
  Paginator pages  | 1092
  Non-page files   | 2557
  Static files     |   76
  Processed images | 2035
  Aliases          |   24
  Sitemaps         |    1
  Cleaned          |    0

Total in 71648 ms

I assume you resize 2015 images on every build, which is going to take time.

What I recommend is that you:

  • Run hugo locally
  • Commit the content of /resources/_gen/images to GitHub
  • A related tip: hugo --gc will clean up unused images in that folder.
7 Likes

Thanks BEP

That really made a big difference as in it dropped 8 minutes off the deploy time on Netlify

1 Like

You could also add this plugin to your netlify.toml file:

[[plugins]]
package = "netlify-plugin-hugo-cache-resources"
1 Like