From 807cae1df11cc83edadcdad29ed762870b5d48fa Mon Sep 17 00:00:00 2001 From: eason <85663565+mango766@users.noreply.github.com> Date: Tue, 24 Mar 2026 00:50:15 +0800 Subject: [PATCH] create: Return error instead of panic when page not found MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When `hugo new` creates a content file on a case-insensitive filesystem where a file with the same name but different case already exists (e.g. Floop.md vs floop.md), the internal page lookup fails because it uses exact string comparison. This previously caused an unhelpful panic. Replace the panic with a descriptive error message that tells the user what went wrong and suggests checking for case-variant filenames. Fixes #14112 Co-authored-by: easonysliu Co-authored-by: Bjørn Erik Pedersen --- create/content.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create/content.go b/create/content.go index 7c04d2f52..519346960 100644 --- a/create/content.go +++ b/create/content.go @@ -271,7 +271,7 @@ func (b *contentBuilder) setArcheTypeFilenameToUse(ext string) { func (b *contentBuilder) applyArcheType(contentFilename string, archetypeFi hugofs.FileMetaInfo) error { p := b.h.GetContentPage(contentFilename) if p == nil { - panic(fmt.Sprintf("[BUG] no Page found for %q", contentFilename)) + return fmt.Errorf("no page found for %q; if a file with the same name but different case already exists, please use a different filename or remove the existing file", contentFilename) } f, err := b.sourceFs.Create(contentFilename) -- 2.39.5