I’m currently working on a theme for my own personal use. I’d like to include a particular page by default on any site that uses this theme, so I created a Markdown file in my theme’s content
directory with the page’s text. At first everything appeared to be working properly, but then I found that this seems to be causing problems with hugo new
. Consider this command:
$ hugo new posts/test.md
panic: [BUG] no Page found for "/path/to/site/themes/mytheme/content/posts/test.md"
goroutine 1 [running]:
github.com/gohugoio/hugo/create.(*contentBuilder).applyArcheType(0xc0008e4000, {0xc0008c4910, 0x4a}, {0xc00070ed10, 0xa})
github.com/gohugoio/hugo/create/content.go:253 +0x354
github.com/gohugoio/hugo/create.(*contentBuilder).buildFile(0xc0008e4000)
github.com/gohugoio/hugo/create/content.go:222 +0x1ad
github.com/gohugoio/hugo/create.NewContent(0xc0001dd1e0, {0x0, 0x0}, {0x7ffeefbffc39, 0x41a9385})
github.com/gohugoio/hugo/create/content.go:98 +0x80d
github.com/gohugoio/hugo/commands.(*newCmd).newContent(0xc000090cf0, 0xc000980c80, {0xc00035bc10, 0x1, 0x0})
github.com/gohugoio/hugo/commands/new.go:83 +0x150
github.com/spf13/cobra.(*Command).execute(0xc000980c80, {0xc00035bbe0, 0x1, 0x1})
github.com/spf13/cobra@v1.2.1/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc000989180)
github.com/spf13/cobra@v1.2.1/command.go:974 +0x3bc
github.com/gohugoio/hugo/commands.Execute({0xc0001840a0, 0x2, 0x2})
github.com/gohugoio/hugo/commands/hugo.go:92 +0xb4
main.main()
github.com/gohugoio/hugo/main.go:23 +0x58
Despite the error, Hugo does manage to create a new file at /path/to/site/themes/mytheme/content/posts/test.md
with the following text:
---
title: "Content Placeholder"
_build:
render: never
list: never
publishResources: false
---
It looks like Hugo is trying—and failing—to create a new post in my theme’s content
directory rather than in my site’s content
directory. Is this expected behavior? If so, is there any other way to process Markdown files in a theme?