HUGO

`hugo new` with a subsection marked as draft is causing a panic

On my website (source: GitHub - BBaoVanC/bbaovanc.com: The source code of my website, uses https://github.com/BBaoVanC/bobatheme), if I do hugo new --kind blog blog/drafts/test, then I get a panic:

panic: [BUG] no Page found for "/home/bbaovanc/git-repos/bbaovanc.com/content/blog/drafts/test/index.md"

goroutine 1 [running]:
github.com/gohugoio/hugo/create.(*contentBuilder).applyArcheType(0xc00025c9c0, {0xc000799e00, 0x47}, {0xc000043340, 0xd})
	/home/bbaovanc/git-repos/hugo/create/content.go:276 +0x354
github.com/gohugoio/hugo/create.(*contentBuilder).buildDir(0xc00025c9c0)
	/home/bbaovanc/git-repos/hugo/create/content.go:179 +0x7c5
github.com/gohugoio/hugo/create.NewContent.func1()
	/home/bbaovanc/git-repos/hugo/create/content.go:93 +0x154
github.com/gohugoio/hugo/create.NewContent(0xc00047b760, {0x7fffdbf2a7bf, 0x4}, {0x7fffdbf2a7c4, 0x5a8f65})
	/home/bbaovanc/git-repos/hugo/create/content.go:108 +0x5fe
github.com/gohugoio/hugo/commands.(*newCmd).newContent(0xc000529230, 0xc0003a0000, {0xc0004b6ff0, 0x1, 0x0})
	/home/bbaovanc/git-repos/hugo/commands/new.go:83 +0x150
github.com/spf13/cobra.(*Command).execute(0xc0003a0000, {0xc0004b6fc0, 0x3, 0x3})
	/home/bbaovanc/.local/share/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc000724780)
	/home/bbaovanc/.local/share/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x3bc
github.com/gohugoio/hugo/commands.Execute({0xc00003c0b0, 0x4, 0x4})
	/home/bbaovanc/git-repos/hugo/commands/hugo.go:92 +0xb4
main.main()
	/home/bbaovanc/git-repos/hugo/main.go:23 +0x58

It’s something in my site specifically though, because if I try this on an empty Hugo site, the same config.yaml, and my theme cloned, then there’s no panic and the archetype is processed properly. The site also generates correctly too.

I cannot reproduce the problem with your data on Ubuntu 20.04.3 LTS using v0.89.4.

git clone --recurse-submodules https://github.com/BBaoVanC/bbaovanc.com
cd bbaovanc.com/
hugo new --kind blog blog/drafts/test

Content dir “/home/jmooring/temp/bbaovanc.com/content/blog/drafts/test” created

hugo
Start building sites … 
hugo v0.89.4-AB01BA6E+extended linux/amd64 BuildDate=2021-11-17T08:24:09Z VendorInfo=gohugoio

                   | EN | ES  
-------------------+----+-----
  Pages            | 64 | 10  
  Paginator pages  |  3 |  0  
  Non-page files   | 26 |  0  
  Static files     |  4 |  4  
  Processed images |  0 |  0  
  Aliases          | 28 |  1  
  Sitemaps         |  2 |  1  
  Cleaned          |  0 |  0  

Total in 147 ms

Ah, I think I found the issue now. I only get the panic if I have an _index.md inside content/blog/drafts which has draft: true set. If I set it to false or remove the line, it works.

Sorry, still can’t reproduce.

Can you try with these commands?

git clone --recursive https://github.com/BBaoVanC/bbaovanc.com.git
cd bbaovanc.com
mkdir content/blog/drafts/
echo -e '---\ndraft: true\n---' > content/blog/drafts/_index.md
hugo new blog/drafts/test

I can reproduce with those commands on:

  • my main computer (Arch Linux)
  • archlinux:base-devel Docker image
  • ubuntu:jammy Docker image
  • debian:sid Docker image
  • my MacBook (0.89.4 from Homebrew)

Arch Linux, Ubuntu, and Debian repos are out of date, but I can also reproduce it with a binary I built off of the 0.89.4 tag.

Here’s hugo env on my binary I built:

hugo v0.89.4 linux/amd64 BuildDate=unknown
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.17.3"
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.