Prevent static file copy if not needed in dev mode

Is there a way to prevent hugo from copying static file if they already exists?

When I lauch hugo server, my site take about 2 minutes to build. I have got a lot of images, and thumbnails of this images, so there are like 1750 static files, a lot of wich do never change. I launch the server with “–render to disk” and “-d” option, but it seems hugo still copies all the static files, even if they already exists in the destination directory. Is there a way to prevent hugo copying already existing static files when launching the server ?

      cache     cumulative       average       maximum
  potential       duration      duration      duration  count  template
      -----     ----------      --------      --------  -----  --------
          0   23.8675004s  140.397061ms    4.0447003s    170  partials/cards/generic.html
          0    21.287829s  1.935257181s    7.5990885s     11  _default\list.html
          0   18.6400117s  152.786981ms    3.4383476s    122  partials/cards/summary.html
          0   14.5559805s  501.930362ms    1.7679686s     29  shortcodes/gallery.html
          0    5.9416877s   49.104857ms    605.3569ms    121  partials/cards/image.html
          0    2.7513059s   12.014436ms    1.1773091s    229  _default\single.html
          0    2.5950737s    2.5950737s    2.5950737s      1  index.html
          0    2.1945525s    2.1945525s    2.1945525s      1  partials/home/blog.html
          0    1.6994474s    48.55564ms    124.4608ms     35  shortcodes/image.html
          0    1.6961998s    7.406986ms    1.1363703s    229  partials/single/related.html
          0    993.7502ms   28.392862ms     660.268ms     35  partials/trombi.html

Are you saying that this happen even on rebuilds or only on the initial build?

I have to dig into the code to double check what we do here, but at least for the rebuilds it should only (by default, if not using the --forceSyncStatic flag) sync changed files.

I do, however, vaguely remember some issues reported in the past. @anthonyfok may have better memory (he is younger…)

I think this may have been part of the reason why we added these flags, you can try:


1 Like

This happen on the initial build. Rebuild time is a lot shorter. The options --noChmod and--noTimes didn’t help to shorten the initial build time.

That doesn’t sound right. Could you create an issue here:

And I will (eventually) have a look at it.

I posted the issue here