hugo: Panic with hugo new with directory archetype in multilingual site

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

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

Does this issue reproduce with the latest release?

$ hugo new posts/2021/11/12323

panic: [BUG] no Page found for "[...]content/ru/posts/2021/11/12323/index.md"

goroutine 1 [running]:
github.com/gohugoio/hugo/create.(*contentBuilder).applyArcheType(0xc00025c840, {0xc000888af0, 0x65}, {0xc000379b70, 0xe})
	/root/project/hugo/create/content.go:276 +0x354
github.com/gohugoio/hugo/create.(*contentBuilder).buildDir(0xc00025c840)
	/root/project/hugo/create/content.go:179 +0x7c5
github.com/gohugoio/hugo/create.NewContent.func1()
	/root/project/hugo/create/content.go:93 +0x154
github.com/gohugoio/hugo/create.NewContent(0xc000492fd0, {0x0, 0x0}, {0x7ffd9e3173e4, 0x66f045})
	/root/project/hugo/create/content.go:108 +0x5fe
github.com/gohugoio/hugo/commands.(*newCmd).newContent(0xc00048df80, 0xc0003d8f00, {0xc0003fc2b0, 0x1, 0x0})
	/root/project/hugo/commands/new.go:83 +0x150
github.com/spf13/cobra.(*Command).execute(0xc0003d8f00, {0xc0003fc220, 0x1, 0x1})
	/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc000584280)
	/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x3bc
github.com/gohugoio/hugo/commands.Execute({0xc00003c0a0, 0x2, 0x2})
	/root/project/hugo/commands/hugo.go:92 +0xb4
main.main()
	/root/project/hugo/main.go:23 +0x58
$ hugo new posts/2021/12

panic: [BUG] no Page found for "[...]/content/ru/posts/2021/12/index.md"

goroutine 1 [running]:
github.com/gohugoio/hugo/create.(*contentBuilder).applyArcheType(0xc000274600, {0xc000044b40, 0x5f}, {0xc00013a040, 0xe})
	/root/project/hugo/create/content.go:276 +0x354
github.com/gohugoio/hugo/create.(*contentBuilder).buildDir(0xc000274600)
	/root/project/hugo/create/content.go:179 +0x7c5
github.com/gohugoio/hugo/create.NewContent.func1()
	/root/project/hugo/create/content.go:93 +0x154
github.com/gohugoio/hugo/create.NewContent(0xc0000a9550, {0x0, 0x0}, {0x7ffde3c863ea, 0x66f045})
	/root/project/hugo/create/content.go:108 +0x5fe
github.com/gohugoio/hugo/commands.(*newCmd).newContent(0xc0002b1a10, 0xc00069db80, {0xc0002ede10, 0x1, 0x0})
	/root/project/hugo/commands/new.go:83 +0x150
github.com/spf13/cobra.(*Command).execute(0xc00069db80, {0xc0002edde0, 0x1, 0x1})
	/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc0003f0f00)
	/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x3bc
github.com/gohugoio/hugo/commands.Execute({0xc00011c070, 0x2, 0x2})
	/root/project/hugo/commands/hugo.go:92 +0xb4
main.main()
	/root/project/hugo/main.go:23 +0x58

BUT…

$ hugo new posts/test

Content dir "[...]/content/ru/posts/test" created
$ cat themes/ui-base/archetypes/posts/index.md
---
{{ $title := ((replace .Name "-" " ") | title) -}}
{{ $hash := (((printf "%s.%d.%s" ("6ba7b811-9dad-11d1-80b4-00c04fd430c8") (now.Unix) (delimit (shuffle (seq 999)) "")) | base64Encode) | sha1) -}}
{{ $uuid := (printf "%s-%s-5%s-%s%s-%s" (substr $hash 0 8) (substr $hash 8 4) (substr $hash 13 3) (index (slice "8" "9" "a" "b" | shuffle) 0) (substr $hash 17 3) (substr $hash 20 12)) -}}

title: '{{ $title }}'
description: ''

# --------------------------------------------------------------------------- #
# Meta.
# --------------------------------------------------------------------------- #

categories:
  - ''
tags:
  - ''

date: '{{ .Date }}'
hash: '{{ $hash }}'
uuid: '{{ $uuid }}'
slug: '{{ $uuid }}'

draft: 1
---

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 19 (5 by maintainers)

Most upvoted comments

Just Use .md at the end solved it

hugo new classy-cv
Error: failed to resolve "classy-cv" to a archetype template

hugo new portafolio/classy-cv.md
Content "D:\\programming\\apps\\hugo_0.98.0_Windows-64bit\\portafolio\\content\\portafolio\\classy-cv.md" created

@KitsuneSolar I know. That’s why the issue is still open.

This appears to be limited to directory archetypes in multilingual sites, triggered by the order in which you create content. The presence of a theme is irrelevant.

Simplified MRE

git clone --single-branch -b hugo-github-issue-9204 https://github.com/jmooring/hugo-testing hugo-github-issue-9204
cd hugo-github-issue-9204
hugo new content/en/post/test   # defaultContentLanguage
hugo new content/de/post/test

Now, clear the content directories, then create the content in reverse order.

rm -rf content/en/* content/de/*
hugo new content/de/post/test
hugo new content/en/post/test   # defaultContentLanguage

To avoid the error:

  • If the defaultContentLanguage is en, create the de content first.
  • If the defaultContentLanguage is de, create the en content first.