Closed Jieiku closed 4 years ago
The default archetype already does the same thing (other than the trick with the image date):
$ hugo new posts/hello-world.md
$ cat content/posts/hello-world.md
+++
title = "Hello World"
date = 2020-01-26T09:09:02+02:00
images = ["/2016/10/image.jpg"]
description = ""
categories = ["category"]
tags = ["tag1", "tag2"]
draft = true
+++
hmmm interesting, for me the default one did not work. I will have to investigate further.
$ hugo new posts/`date +%Y/%m`/hello-world.md
$ cat content/posts/2020/01/hello-world.md
---
title: "Hello World"
date: 2020-01-26T01:27:06-08:00
draft: true
---
I figured it out! So your archetype file in the theme is labeled default.md however hugo comes installed with a file also called default.md and so if you have that file present then the one included with your theme never gets applied.
As a new user to Hugo, I would not have known to delete the default.md that ships with Hugo in order for the one included with your theme to work.
However if you rename the one included with your theme from default.md to posts.md then it completely circumvents the issue altogether.
this posts archetype speeds up creation of new posts. By giving you a template for all frontmatter. For example if you create a new post from the command line:
This new post will be in the proper directory structure:
/content/posts/2020/01/hello-world.md
Additionally if you look at the front matter you will see that the images front matter has the correct date directory structure: