I run hugo server
for previewing my site locally with this PowerShell script:
[console]::WindowWidth=120
[console]::WindowHeight=30
[console]::BufferWidth=[console]::WindowWidth
$host.ui.RawUI.WindowTitle = "Test Server"
Set-Location -LiteralPath (Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path))
Remove-Item "public" -Recurse -ErrorAction "Ignore"
Remove-Item "resources" -Recurse -ErrorAction "Ignore"
# Fast Render: Home page + Content page last edited (if any) + Content page last visited (up to 10)
hugo server ārenderToMemory --printMemoryUsage --disableFastRender -D -p 80
But site rebuilding takes too much time, especially if only few words has been changed in single file.
Watching for changes in [PATH TO SITE SOURCE]\{archetypes,assets,content,data,i18n,layouts,package.hugo.json,package.json,static}
Watching for config changes in [PATH TO SITE SOURCE]\config\_default, [PATH TO SITE SOURCE]\config\development, [PATH TO SITE SOURCE]\go.mod
Start building sites ā¦
hugo v0.125.7-b1d808bc373f53ad37c8966bb02a6aea095db5f8+extended windows/amd64 BuildDate=2024-05-08T14:46:24Z VendorInfo=gohugoio
Alloc = 402.7 MB
TotalAlloc = 1.2 GB
Sys = 536.5 MB
NumGC = 24
Alloc = 914.6 MB
TotalAlloc = 2.2 GB
Sys = 967.6 MB
NumGC = 26
Alloc = 1.5 GB
TotalAlloc = 3.2 GB
Sys = 1.6 GB
NumGC = 27
Alloc = 1.2 GB
TotalAlloc = 4.4 GB
Sys = 1.9 GB
NumGC = 29
Alloc = 1.2 GB
TotalAlloc = 5.3 GB
Sys = 2.0 GB
NumGC = 30
Alloc = 1.6 GB
TotalAlloc = 6.5 GB
Sys = 2.1 GB
NumGC = 31
| KO
-------------------+------
Pages | 501
Paginator pages | 203
Non-page files | 1
Static files | 4
Processed images | 9
Aliases | 62
Cleaned | 0
Built in 30342 ms
Alloc = 1.8 GB
TotalAlloc = 6.6 GB
Sys = 2.1 GB
NumGC = 31
Environment: "development"
Serving pages from disk
Web Server is available at http://localhost:80/ (bind address 127.0.0.1)
Press Ctrl+C to stop
Change detected, rebuilding site (#1).
2024-05-12 18:03:02.704 +0900
Source changed /b/game/the-division/016-eagle-sharer-2/index.md
Web Server is available at http://localhost:80/ (bind address 127.0.0.1)
Total in 71126 ms
Change detected, rebuilding site (#2).
2024-05-12 18:07:37.207 +0900
Source changed /b/game/the-division/016-eagle-sharer-2/index.md
Web Server is available at http://localhost:80/ (bind address 127.0.0.1)
Total in 68745 ms
Change detected, rebuilding site (#3).
2024-05-12 18:09:54.698 +0900
Source changed /b/game/the-division/001-happy-picture-mode/index.md
Web Server is available at http://localhost:80/ (bind address 127.0.0.1)
Total in 66554 ms
Change detected, rebuilding site (#4).
2024-05-12 18:11:01.253 +0900
Source changed /b/game/the-division/001-happy-picture-mode/index.md
Web Server is available at http://localhost:80/ (bind address 127.0.0.1)
Total in 70131 ms
Change detected, rebuilding site (#5).
2024-05-12 18:12:16.211 +0900
Source changed /b/game/the-division/002-todays-division-2/index.md
Web Server is available at http://localhost:80/ (bind address 127.0.0.1)
Total in 69935 ms
As you can see, initial site building time is not that bad (around 30 seconds), but site rebuilding takes too much time (more than 60 seconds), even if all Iāve changed is just a word in single file.
I also tested if removing --disableFastRender
would speed up rebuild process, but that didnāt change anything. Site rebuilding still takes long time, more than 60 seconds.
Since both Hugo executable and site source is on SSD, I donāt think it is related to slow I/O.
Here is what hugo --templateMetrics --templateMetricsHints
shows. I posted it in separate site because it is too long.
This is what hugo env
says.
hugo v0.125.7-b1d808bc373f53ad37c8966bb02a6aea095db5f8+extended windows/amd64 BuildDate=2024-05-08T14:46:24Z VendorInfo=gohugoio
GOOS="windows"
GOARCH="amd64"
GOVERSION="go1.22.2"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.3.2"
What can be the reason of this slow site rebuild? How can I solve it?
PS. Iāve set my site source repository as private. If you need anything about my siteās source, please tell me.