Create new page with different archetypes

I run command hugo new post/title.md to create a new page, and I need to create pages with different archetypes, such as hugo new post/title.md uses archetype default.md, and hugo new post/foo.md uses archetype bar.md.

How? Thank you.

Give this file tree:

├── archetypes
│   ├── default.md
│   └── post.md
├── content
│   ├── post
│   │   └── title.md
│   └── regular
│       └── title.md

Then running

hugo new regular/title.md

Will use this archetype

archetypes/default.md

And running

hugo new post/title.md

Will use this archetype

archetypes/post.md

You can also specify the archetype to be used while running hugo new.

Assuming you have this structure,

├── archetypes
│   ├── default.md
│   ├── post.md
│   └── page.md
├── content
│   ├── pages
│   │   └── page1.md
│   └── posts
│       └── post1.md

You can use the -k flag like this to create new files with a specific archetype:

hugo new -k post posts/post2.md
hugo new -k page pages/page2.md

Thank you.

Thank you too.

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