Skip to content

Commit

Permalink
Fix rebuild when changing mixed case named templates
Browse files Browse the repository at this point in the history
Fixes #12165
  • Loading branch information
bep committed Mar 20, 2024
1 parent c1ea22a commit 19937a2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hugolib/hugo_sites_build.go
Expand Up @@ -730,7 +730,7 @@ func (h *HugoSites) processPartial(ctx context.Context, l logg.LevelLogger, conf

case files.ComponentFolderLayouts:
tmplChanged = true
templatePath := pathInfo.TrimLeadingSlash().PathNoLang()
templatePath := pathInfo.Unnormalized().TrimLeadingSlash().PathNoLang()
if !h.Tmpl().HasTemplate(templatePath) {
tmplAdded = true
}
Expand Down
24 changes: 24 additions & 0 deletions hugolib/rebuild_test.go
Expand Up @@ -1490,3 +1490,27 @@ title: "Default"
// Just make sure that it doesn't panic.
b.EditFileReplaceAll("archetypes/default.md", "Default", "Default Edited").Build()
}

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

files := `
-- hugo.toml --
baseURL = "https://example.com"
disableLiveReload = true
-- layouts/partials/MyTemplate.html --
MyTemplate
-- layouts/index.html --
MyTemplate: {{ partial "MyTemplate.html" . }}|
`

b := TestRunning(t, files)

b.AssertFileContent("public/index.html", "MyTemplate: MyTemplate")

b.EditFileReplaceAll("layouts/partials/MyTemplate.html", "MyTemplate", "MyTemplate Edited").Build()

b.AssertFileContent("public/index.html", "MyTemplate: MyTemplate Edited")
}

0 comments on commit 19937a2

Please sign in to comment.