Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when creating new content _index.md then index.md #12194

Open
irkode opened this issue Mar 1, 2024 · 4 comments
Open

Panic when creating new content _index.md then index.md #12194

irkode opened this issue Mar 1, 2024 · 4 comments

Comments

@irkode
Copy link

irkode commented Mar 1, 2024

edit: added generated files


Hugo crashed when I accidently executed a rather strange sequence of new content commands:

I consider that as an edge case - but message itself states it as bug

I accidently 1 tried to create *index.md files in the following order (one without underscore)

  1. _index.md
  2. index.md

Hugo crashed with: panic: [BUG] no Page found for "C:\_my\test\content\index.md"

Steps to reproduce: on Windows 10

PS C:_my> hugo version

hugo v0.123.7-312735366b20d64bd61bff8627f593749f86c964+extended windows/amd64 BuildDate=2024-03-01T16:16:06Z VendorInfo=gohugoio

PS C:_my> hugo new site test

Congratulations! Your new Hugo site was created in C:\_my\test.
 ...
See documentation at https://gohugo.io/.

PS C:_my> pushd test
PS C:_my\test> hugo new content _index.md

Content "C:\\_my\\test\\content\\_index.md" created

PS C:_my\test> hugo new content index.md

panic: [BUG] no Page found for "C:\\_my\\test\\content\\index.md"

goroutine 1 [running]:
github.com/gohugoio/hugo/create.(*contentBuilder).applyArcheType(0xc000a30840, {0xc000a58150, 0x1c}, {0x4a0bde0, 0xc0003097c0})
       /root/project/hugo/create/content.go:275 +0x354
github.com/gohugoio/hugo/create.(*contentBuilder).buildFile(0xc000a30840)
       /root/project/hugo/create/content.go:244 +0x1ad
github.com/gohugoio/hugo/create.NewContent.func1()
       /root/project/hugo/create/content.go:105 +0x28c
github.com/gohugoio/hugo/create.NewContent(0xc0007d8c80, {0x0, 0x0}, {0xc00000a100, 0x8}, 0x0)
       /root/project/hugo/create/content.go:108 +0x5c6
github.com/gohugoio/hugo/commands.newNewCommand.func1({0x0?, 0x0?}, 0x0?, 0xc000612dc0, {0xc00049bd50, 0x0?, 0x0?})
       /root/project/hugo/commands/new.go:60 +0x15f
github.com/gohugoio/hugo/commands.(*simpleCommand).Run(0x0?, {0x4a010d8?, 0x5d46a00?}, 0x0?, {0xc00049bd50?, 0xc0008d7a28?, 0x0?})
       /root/project/hugo/commands/commandeer.go:596 +0x3c
github.com/bep/simplecobra.(*Commandeer).compile.func1(0xc0009acb00?, {0xc00049bd50?, 0x4?, 0x320c1bf?})
       /root/project/gomodcache/github.com/bep/[email protected]/simplecobra.go:113 +0x4c
github.com/spf13/cobra.(*Command).execute(0xc0006dc608, {0xc00049bd10, 0x1, 0x1})
       /root/project/gomodcache/github.com/spf13/[email protected]/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc0009b4908)
       /root/project/gomodcache/github.com/spf13/[email protected]/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
       /root/project/gomodcache/github.com/spf13/[email protected]/command.go:1048
github.com/bep/simplecobra.(*Exec).Execute(0xc0004b6820, {0x4a010d8?, 0x5d46a00?}, {0xc0000ac090?, 0x101?, 0xc000099e88?})
       /root/project/gomodcache/github.com/bep/[email protected]/simplecobra.go:155 +0xd4
github.com/gohugoio/hugo/commands.Execute({0xc0000ac090, 0x3, 0x3})
       /root/project/hugo/commands/commandeer.go:66 +0x2f9
main.main()
       /root/project/hugo/main.go:25 +0x56
  • content of _index.md - taken from archetypes/default.md

    +++
    title = ''
    date = 2024-03-01T22:14:48+01:00
    draft = true
    +++
  • content of _index.md

    ---
    title: "Content Placeholder"
    _build:
      render: never
      list: never
      publishResources: false
    ---
    

Footnotes

  1. hurray for Copy'n'Paste and shell history ;-)

@jmooring
Copy link
Member

jmooring commented Mar 2, 2024

Summary...

hugo new site foo
cd foo
hugo new _index.md
hugo new index.md

This was not a problem with v0.122.0. Fails with v0.123.0 and later.

@jmooring jmooring changed the title Hugo aborts with panic [BUG] when creating new content _index.md and then index.md Panic when creating new content _index.md then index.md Mar 2, 2024
@bep bep modified the milestones: v0.123.9, v0.124.1 Mar 13, 2024
@bep bep modified the milestones: v0.124.1, v0.124.2 Mar 26, 2024
@bep bep modified the milestones: v0.124.2, v0.126.0 Apr 17, 2024
@ca5ua1
Copy link

ca5ua1 commented May 7, 2024

I have something that might be related to this issue on hugo v0.125.4+extended linux/amd64 BuildDate=unknown VendorInfo=nixpkgs.

In my issue - when there is index.md - hugo doesn't generate content for any subfolders.
E.g. if there is content/myFolder/post.md it will not generate in public

@jmooring
Copy link
Member

jmooring commented May 7, 2024

@ca5ua1 If you have a directory with descendant pages it is a branch bundle, and you must use an _index.md file instead of an index.md file. See documentation.

@ca5ua1
Copy link

ca5ua1 commented May 7, 2024

@jmooring ah, I see. That's confusing. Thanks for pointing that out

@bep bep modified the milestones: v0.126.0, v0.127.0 May 15, 2024
@bep bep modified the milestones: v0.127.0, v0.128.0 Jun 8, 2024
@bep bep modified the milestones: v0.128.0, v0.129.0 Jun 21, 2024
@bep bep modified the milestones: v0.129.0, v0.131.0 Jul 22, 2024
@bep bep modified the milestones: v0.131.0, v0.133.0 Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants