Can you use Markdown files for default content in a theme?

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/
panic: [BUG] no Page found for "/path/to/site/themes/mytheme/content/posts/"

goroutine 1 [running]:*contentBuilder).applyArcheType(0xc0008e4000, {0xc0008c4910, 0x4a}, {0xc00070ed10, 0xa}) +0x354*contentBuilder).buildFile(0xc0008e4000) +0x1ad, {0x0, 0x0}, {0x7ffeefbffc39, 0x41a9385}) +0x80d*newCmd).newContent(0xc000090cf0, 0xc000980c80, {0xc00035bc10, 0x1, 0x0}) +0x150*Command).execute(0xc000980c80, {0xc00035bbe0, 0x1, 0x1}) +0x60e*Command).ExecuteC(0xc000989180) +0x3bc{0xc0001840a0, 0x2, 0x2}) +0xb4
main.main() +0x58

Despite the error, Hugo does manage to create a new file at /path/to/site/themes/mytheme/content/posts/ with the following text:

title: "Content Placeholder"
  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?

To answer your question: Yes you can.

The error you get is a bug (see issue below) and I will fix it. I rewrote that feature for the latest release, and I seem to have missed something vs. themes.

Question: Dir you run “hugo new posts/” from the theme or from the project?

1 Like

Got it! Good to know that this is a known issue. :+1:

Oh, sorry I wasn’t clear: I ran hugo new from the site’s top-level directory.

Just out of curiosity, is hugo new supposed to generate a new post in the theme’s content directory if it is run from within a theme, instead?

Well, it wasn’t a known issue until you told me about it.

That said, I’m having problems reproducing it on my MacBook. What OS are you running? Do you have a simple step-by-step variant that fails like this?

I believe I have reproduced and identified the config causing the issue in


I do! I’ll post step-by-step instructions in the GitHub issue.