Skip to content

Commit

Permalink
Fix server refresh on 404 template changes
Browse files Browse the repository at this point in the history
Fixes #13209
  • Loading branch information
bep committed Jan 2, 2025
1 parent 2db43f8 commit d913f46
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
31 changes: 31 additions & 0 deletions hugolib/404_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package hugolib

import (
"fmt"
"testing"
)

Expand Down Expand Up @@ -82,3 +83,33 @@ Page not found
Base:
Page not found`)
}

func Test404EditTemplate(t *testing.T) {
t.Parallel()

files := `
-- hugo.toml --
baseURL = "http://example.com/"
disableLiveReload = true
[internal]
fastRenderMode = true
-- layouts/_default/baseof.html --
Base: {{ block "main" . }}{{ end }}
-- layouts/404.html --
{{ define "main" }}
Not found.
{{ end }}
`

b := TestRunning(t, files)

b.AssertFileContent("public/404.html", `Not found.`)

b.EditFiles("layouts/404.html", `Not found. Updated.`).Build()

fmt.Println("Rebuilding")
b.BuildPartial("/does-not-exist")

b.AssertFileContent("public/404.html", `Not found. Updated.`)
}
3 changes: 2 additions & 1 deletion hugolib/content_map_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ func (h *HugoSites) resolveAndResetDependententPageOutputs(ctx context.Context,

po.renderState = 0
po.p.resourcesPublishInit = &sync.Once{}
if r == identity.FinderFoundOneOfMany {
if r == identity.FinderFoundOneOfMany || po.f.Name == output.HTTPStatusHTMLFormat.Name {
// Will force a re-render even in fast render mode.
po.renderOnce = false
}
Expand Down Expand Up @@ -1310,6 +1310,7 @@ func (h *HugoSites) resolveAndResetDependententPageOutputs(ctx context.Context,
if !po.isRendered() {
continue
}

for _, id := range changes {
checkedCounter.Add(1)
if r := depsFinder.Contains(id, po.dependencyManagerOutput, 50); r > identity.FinderFoundOneOfManyRepetition {
Expand Down

0 comments on commit d913f46

Please sign in to comment.