Hugo is really slow the first time I run it (MacOS - a solution)

“Every day, the first time I run Hugo it’s very, very slow…”

hugo v0.109.0+extended darwin/amd64 BuildDate=unknown

                   | EN   
-------------------+------
  Pages            | 125  
  Paginator pages  |   3  
  Non-page files   |  39  
  Static files     |   9  
  Processed images |   0  
  Aliases          |   4  
  Sitemaps         |   1  
  Cleaned          |   0  

Total in 275552 ms

…and if I immediately run Hugo again, it’s blisteringly quick:

hugo v0.109.0+extended darwin/amd64 BuildDate=unknown

                   | EN   
-------------------+------
  Pages            | 125  
  Paginator pages  |   3  
  Non-page files   |  39  
  Static files     |   9  
  Processed images |   0  
  Aliases          |   4  
  Sitemaps         |   1  
  Cleaned          |   0  

Total in 347 ms

In case you’re seeing this… here might be the reason: you’re using Google Drive or Dropbox to store your Hugo files on your Mac. Not a bad plan in the past.

The new versions of Google Drive and Dropbox don’t keep your files on your computer for very long, and instead “stream” them from the cloud. Normally, that’s fine, but in Hugo’s case, it’s looking at every single file in your site’s folder, which could be hundreds: and it needs to download all of those before it can make your site. Hence the big wait the first time (nearly five minutes), and the fast speed the second.

The solution: go to your Hugo website files folder in Finder, and hit the “download from the cloud” icon. That will ensure that a copy is always cached on your computer; and mean that Hugo doesn’t need to wait for every file to be downloaded all over again.

What if you configure file caches instead?

yes and the first time the cache is empty

I think @jamescridland is right about his issue being Google Drive or similar.

1 Like

Assuming you’re using Git, you probably shouldn’t be storing your project on any cloud service. Although the following refers specifically to Apple’s iCloud Drive, it still may be worth considering regarding cloud services in general

I have hundreds of images and my builds were also 5-10 minutes long until I found out files can be cached. But even with the cache, the first build per session still takes more time to initialize (30-60 seconds).

My source code is stored in my iCloud storage and I work directly on the project directory there. For years now. So far I have never had any problems. If you have only one PC, it makes no sense to store the source code in the cloud. But if there are several workstations, no matter where, then it is very comfortable to always have access to the same source code. Currently I still have macOS 12.6.2 and Hugo version 0.109.0.