gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
73.49k stars 7.37k forks source link

hugo new panics when folder name contains a date #12599

Open pawelgrzybek opened 2 weeks ago

pawelgrzybek commented 2 weeks ago

What version of Hugo are you using (hugo version)?

hugo v0.127.0+extended darwin/arm64 BuildDate=2024-06-05T10:27:59Z VendorInfo=brew

Does this issue reproduce with the latest release?

Yes


I use leaf bundles for my posts. I infer date of my posts from the folder name. I have this in my config.

[frontmatter]
  date = [':filename', ':default']

Assuming I have this archetype under archetypes/posts/index.md

---
title: "Title goes here"
summary: "Summary goes here."
---

When I run hugo new posts/test it works as expected. If I run a hugo new posts/2024-06-17-test, I am receiving an error.

panic: [BUG] no Page found for "/Users/pawelgrzybek/Sites/pawelgrzybek.com/content/posts/2024-06-17-test/index.md"

goroutine 1 [running]:
github.com/gohugoio/hugo/create.(*contentBuilder).applyArcheType(0x14000b2ccc0, {0x14000b0b200, 0x59}, {0x104034360, 0x14000373140})
    github.com/gohugoio/hugo/create/content.go:273 +0x2b8
github.com/gohugoio/hugo/create.(*contentBuilder).buildDir(0x14000b2ccc0)
    github.com/gohugoio/hugo/create/content.go:179 +0x51c
github.com/gohugoio/hugo/create.NewContent.func1()
    github.com/gohugoio/hugo/create/content.go:92 +0x268
github.com/gohugoio/hugo/create.NewContent(0x140009b6000, {0x0, 0x0}, {0x16f9b3a79, 0x15}, 0x0)
    github.com/gohugoio/hugo/create/content.go:106 +0x480
github.com/gohugoio/hugo/commands.newNewCommand.func1({0x0?, 0x0?}, 0x0?, 0x140008a8c80, {0x140008f1250, 0x0?, 0x0?})
    github.com/gohugoio/hugo/commands/new.go:60 +0x160
github.com/gohugoio/hugo/commands.(*simpleCommand).Run(0x0?, {0x1040292e8?, 0x105475840?}, 0x0?, {0x140008f1250?, 0xa6fa80a000000000?, 0x140008059f8?})
    github.com/gohugoio/hugo/commands/commandeer.go:618 +0x48
github.com/bep/simplecobra.(*Commandeer).compile.func1(0x140006c3000?, {0x140008f1250?, 0x4?, 0x1021ccd37?})
    github.com/bep/simplecobra@v0.4.0/simplecobra.go:113 +0x54
github.com/spf13/cobra.(*Command).execute(0x140008faf08, {0x140008f1210, 0x1, 0x1})
    github.com/spf13/cobra@v1.8.0/command.go:983 +0x840
github.com/spf13/cobra.(*Command).ExecuteC(0x1400056b208)
    github.com/spf13/cobra@v1.8.0/command.go:1115 +0x344
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
    github.com/spf13/cobra@v1.8.0/command.go:1048
github.com/bep/simplecobra.(*Exec).Execute(0x14000091320, {0x1040292e8?, 0x105475840?}, {0x140002b0a80?, 0x103bb7e40?, 0x100496028?})
    github.com/bep/simplecobra@v0.4.0/simplecobra.go:155 +0xb4
github.com/gohugoio/hugo/commands.Execute({0x1400004e4c0, 0x2, 0x2})
    github.com/gohugoio/hugo/commands/commandeer.go:68 +0x284
main.main()
    github.com/gohugoio/hugo/main.go:25 +0x70

Here is a repo where I am facing this issue: https://github.com/pawelgrzybek/pawelgrzybek.com

jmooring commented 2 weeks ago

Problem occurs with v0.123.0 and later.

pawelgrzybek commented 2 weeks ago

Thanks for confirming that @jmooring