# Using archetypes

**URL:** <https://discourse.gohugo.io/t/using-archetypes/36250>\
**Category:** support\
**Created:** [December 28, 2021, 1:18pm UTC](https://discourse.gohugo.io/t/using-archetypes/36250 "2021-12-28T13:18:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![esawertu](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@esawertu](https://discourse.gohugo.io/u/esawertu)\
**Post date:** [December 28, 2021, 1:18pm UTC](https://discourse.gohugo.io/t/using-archetypes/36250/1 "2021-12-28T13:18:29Z")

</div>

My content structure is as follows: `/content/posts/folder-name`. I have six folders inside `/posts/`. I would like to create two archetype templates that populate the same frontmatter for the first 5 folders, and a different one for the 6th folder. Is there a way to do that? I tried using the command `hugo new posts/6th-folder-name` but it creates a folder instead of a file. I have the main template inside `archetypes/posts` and the other inside `archetypes/posts/6th-folder-name`. (The current one creates the post inside the posts folder and I copy-paste it to the folder it belongs. But if there is a way to target each individual folder, I would appreciate too).

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [December 28, 2021, 1:30pm UTC](https://discourse.gohugo.io/t/using-archetypes/36250/2 "2021-12-28T13:30:11Z")

</div>

There is a concept called “sections” in Hugo. Sections are basically the first level folders. You could create two sections and use in that one section with one subfolder with frontmatter `slug` and/or `url` parameters so you can define the resulting URL.

It appears your want `posts/` being the first part of any url in those 6 folders. You would put the five identical subfolders into the `content/posts/foldername` folders and for the sixth section you oput them into `content/specialposts/` and use the following frontmatter:

```auto
url: /posts/special-section/linkname

```

and then you can have an archetype for `posts` and one for `specialposts`.

Hope that makes sense somehow 🙂

---

<div class="post-metadata">

**Author:** ![esawertu](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@esawertu](https://discourse.gohugo.io/u/esawertu)\
**Post date:** [December 28, 2021, 1:38pm UTC](https://discourse.gohugo.io/t/using-archetypes/36250/3 "2021-12-28T13:38:20Z")

</div>

> [@davidsneighbour](#):
>
> Hope that makes sense somehow

It does, but that would disrupt my URLs and taxonomy. I was thinking there was a simpler way to achieve this without disrupting the current order. Alternatively, I can retain the same file in archetypes for all folders, but how would I use the `hugo new` command so that each post appears in the folder I want it to appear in? (Since using `hugo new /posts/folder-name` generates the folder name instead of the post?)

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [December 28, 2021, 2:06pm UTC](https://discourse.gohugo.io/t/using-archetypes/36250/4 "2021-12-28T14:06:46Z")

</div>

`slug` and `url` regulate your URLs, so it actually does NOT disrupt whatever you have going on there. Archetypes are possible per section only.

---

<div class="post-metadata">

**Author:** ![esawertu](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@esawertu](https://discourse.gohugo.io/u/esawertu)\
**Post date:** [December 28, 2021, 2:10pm UTC](https://discourse.gohugo.io/t/using-archetypes/36250/5 "2021-12-28T14:10:01Z")

</div>

> [@davidsneighbour](#):
>
> put them into `content/specialposts/` and use the following frontmatter:

Doing this makes my taxonomy page for this folder disappear. It seems the category works only when the posts are inside the posts folder.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [December 28, 2021, 2:10pm UTC](https://discourse.gohugo.io/t/using-archetypes/36250/6 "2021-12-28T14:10:38Z")

</div>

```nohighlight
archetypes/
├── default.md
└── foo.md

```

For the first 5 directories:

```auto
hugo new posts/dir/xxx.md

```

For the sixth (different) directory:

```nohighlight
hugo new -k foo posts/dir-6/xxx.md

```

---

<div class="post-metadata">

**Author:** ![esawertu](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@esawertu](https://discourse.gohugo.io/u/esawertu)\
**Post date:** [December 28, 2021, 2:19pm UTC](https://discourse.gohugo.io/t/using-archetypes/36250/7 "2021-12-28T14:19:52Z")

</div>

@jmooring that does the trick. Thanks

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [December 30, 2021, 2:20pm UTC](https://discourse.gohugo.io/t/using-archetypes/36250/8 "2021-12-30T14:20:20Z")

</div>

Closed on December 30, 2021, 2:20pm UTC

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