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

hugo new with subsections causes a panic #9146

Closed
BBaoVanC opened this issue Nov 9, 2021 · 8 comments
Closed

hugo new with subsections causes a panic #9146

BBaoVanC opened this issue Nov 9, 2021 · 8 comments

Comments

@BBaoVanC
Copy link

BBaoVanC commented Nov 9, 2021

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

$ hugo version
hugo v0.89.2+extended linux/amd64 BuildDate=unknown

Does this issue reproduce with the latest release?

Yes (I actually just updated it)

Issue

I have an archetype in my theme that's archetypes/blog/index.md and a subsection in my website under content/blog/ which holds my private drafts (content/blog/drafts/). In previous releases I would do hugo new --kind blog blog/drafts/[whatever] (it would actually work without using --kind, but I used it just in case). Now, I get the same error message as #9072.

The issue doesn't happen with the main blog section; only the drafts subsection under it.

Error message for reference:

panic: [BUG] no Page found for "/home/bbaovanc/git-repos/bbaovanc.com/content/blog/drafts/my-thoughts-on-github-copilot/index.md"

goroutine 1 [running]:
github.com/gohugoio/hugo/create.(*contentBuilder).applyArcheType(0xc000542180, {0xc0006410a0, 0x6a}, {0xc00019fd00, 0x10})
	github.com/gohugoio/hugo/create/content.go:268 +0x354
github.com/gohugoio/hugo/create.(*contentBuilder).buildDir(0xc000542180)
	github.com/gohugoio/hugo/create/content.go:175 +0x6c5
github.com/gohugoio/hugo/create.NewContent.func1()
	github.com/gohugoio/hugo/create/content.go:89 +0x154
github.com/gohugoio/hugo/create.NewContent(0xc000805760, {0x7ffeefbff820, 0x4}, {0x7ffeefbff825, 0x41a8f65})
	github.com/gohugoio/hugo/create/content.go:104 +0x5f8
github.com/gohugoio/hugo/commands.(*newCmd).newContent(0xc000616330, 0xc000497180, {0xc000617530, 0x1, 0x0})
	github.com/gohugoio/hugo/commands/new.go:83 +0x150
github.com/spf13/cobra.(*Command).execute(0xc000497180, {0xc000617500, 0x3, 0x3})
	github.com/spf13/cobra@v1.2.1/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc000554a00)
	github.com/spf13/cobra@v1.2.1/command.go:974 +0x3bc
github.com/gohugoio/hugo/commands.Execute({0xc0001a8010, 0x4, 0x4})
	github.com/gohugoio/hugo/commands/hugo.go:92 +0xb4
main.main()
	github.com/gohugoio/hugo/main.go:23 +0x58

The content of the index.md that gets created is also the same as in #9072:

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

If it helps, my website and theme are both on GitHub.

@bep bep added the Bug label Nov 9, 2021
@bep bep added this to the v0.90 milestone Nov 9, 2021
@bep
Copy link
Member

bep commented Nov 9, 2021

Thanks for this; as a general remark, try to write issue titles that describes the problem/bug (what happens). I have a list of 50 Hugo notifications every morning, and "Open
Subsections bring issue #9072 back" doesn't give me much information.

@BBaoVanC
Copy link
Author

BBaoVanC commented Nov 9, 2021

Thanks for this; as a general remark, try to write issue titles that describes the problem/bug (what happens). I have a list of 50 Hugo notifications every morning, and "Open Subsections bring issue #9072 back" doesn't give me much information.

I couldn't think of anything better, here I'll try again

@BBaoVanC BBaoVanC changed the title Subsections bring issue #9072 back hugo new with subsections causes a panic Nov 9, 2021
@bep bep modified the milestones: v0.90, v0.89.3 Nov 11, 2021
bep added a commit to bep/hugo that referenced this issue Nov 12, 2021
@bep
Copy link
Member

bep commented Nov 12, 2021

Even though I'm not able to reproduce the panic (I tested with your site on my MacBook), I do see some discrepancies (if that's even a word ...) with how you use this (I have added a PR that should improve the handling when you have a /default archetype directory).

But when you say:

hugo new --kind blog blog/drafts/foo/index.md 

And the kind resolves to an archetype directory, then you will end up with content/blog/drafts/foo/index.md/index.md which is probably not what you want. You could argue that we should be smarter about this, but it's hard to guess what the user really wants.

bep added a commit that referenced this issue Nov 12, 2021
@BBaoVanC
Copy link
Author

BBaoVanC commented Nov 12, 2021

Even though I'm not able to reproduce the panic (I tested with your site on my MacBook), I do see some discrepancies (if that's even a word ...) with how you use this (I have added a PR that should improve the handling when you have a /default archetype directory).

But when you say:

hugo new --kind blog blog/drafts/foo/index.md 

And the kind resolves to an archetype directory, then you will end up with content/blog/drafts/foo/index.md/index.md which is probably not what you want. You could argue that we should be smarter about this, but it's hard to guess what the user really wants.

Oh wait, I made a typo. I don't put the index.md (so hugo new --kind blog blog/drafts/foo)

I'll have to see if I can test out that commit to see if it made any difference.

@BBaoVanC
Copy link
Author

Just tested it on master (fdad91f), still get the same panic (a couple line numbers are different so I'll paste the error again)

The first line is the command I ran, not part of the output

~/git-repos/bbaovanc.com master -> /home/bbaovanc/.local/share/go/bin/hugo new blog/drafts/abc
panic: [BUG] no Page found for "/home/bbaovanc/git-repos/bbaovanc.com/content/blog/drafts/abc/index.md"

goroutine 1 [running]:
github.com/gohugoio/hugo/create.(*contentBuilder).applyArcheType(0xc00025c480, {0xc00061a730, 0x46}, {0xc000530970, 0xd})
	/home/bbaovanc/git-repos/hugo/create/content.go:272 +0x354
github.com/gohugoio/hugo/create.(*contentBuilder).buildDir(0xc00025c480)
	/home/bbaovanc/git-repos/hugo/create/content.go:175 +0x7c5
github.com/gohugoio/hugo/create.NewContent.func1()
	/home/bbaovanc/git-repos/hugo/create/content.go:89 +0x154
github.com/gohugoio/hugo/create.NewContent(0xc0000db760, {0x0, 0x0}, {0x7fff783a77e7, 0x5a8f65})
	/home/bbaovanc/git-repos/hugo/create/content.go:104 +0x5f8
github.com/gohugoio/hugo/commands.(*newCmd).newContent(0xc00052f920, 0xc0003a0000, {0xc000072fd0, 0x1, 0x0})
	/home/bbaovanc/git-repos/hugo/commands/new.go:83 +0x150
github.com/spf13/cobra.(*Command).execute(0xc0003a0000, {0xc000072f90, 0x1, 0x1})
	/home/bbaovanc/.local/share/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc000630780)
	/home/bbaovanc/.local/share/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x3bc
github.com/gohugoio/hugo/commands.Execute({0xc00003c0a0, 0x2, 0x2})
	/home/bbaovanc/git-repos/hugo/commands/hugo.go:92 +0xb4
main.main()
	/home/bbaovanc/git-repos/hugo/main.go:23 +0x58

@jmooring
Copy link
Member

I am unable to reproduce this with v0.89.4.

archetypes/
├── blog/
│   └── index.md
└── default.md
hugo new --kind blog blog/drafts/foo
content/
└── blog/
    └── drafts/
        └── foo/
            └── index.md

@bep bep closed this as completed Nov 20, 2021
@BBaoVanC
Copy link
Author

That's weird, it's still happening for me. I guess I'll go to https://discourse.gohugo.io/

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants