# Problem creating archetype

**URL:** <https://discourse.gohugo.io/t/problem-creating-archetype/36792>\
**Category:** support\
**Created:** [January 26, 2022, 8:48pm UTC](https://discourse.gohugo.io/t/problem-creating-archetype/36792 "2022-01-26T20:48:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![golodhrim](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/golodhrim/32/16103_2.png) [@golodhrim](https://discourse.gohugo.io/u/golodhrim)\
**Post date:** [January 26, 2022, 8:48pm UTC](https://discourse.gohugo.io/t/problem-creating-archetype/36792/1 "2022-01-26T20:48:08Z")

</div>

hi everybody, i try to create an archetype so that i can use it, and i always run into some problems. it might be multiple ones.

1. I would like to get the foldername “folder” from path/folder/name that should create a posts/path/folder/name.md structure to use it in the archetype.

2. I would like to specify somewhere (needs to be figured out where) a list of translations so that I can use these values based on the variable from 1

any help would be welcome.

example of archetypes/posts.md

```auto
---
title: "{{ replace .TranslationBaseName "-" " " | title }}"
date: {{ .Date }}
# hero: /images/posts/{{ question 1 }}/image.png
description: Short Description
menu:
  sidebar:
    name: {{ replace .TranslationBaseName "-" " " }}
    identifier: {{ question 2 }}
    weight: 10
tags: ["Basic", "Multi-lingual"]
categories: ["Basic"]
---

**Insert Lead paragraph here.**

```

---

<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:** [January 27, 2022, 12:23am UTC](https://discourse.gohugo.io/t/problem-creating-archetype/36792/2 "2022-01-27T00:23:35Z")

</div>

Initial comments:

1. Use `.File.ContentBaseName` instead of `.TranslationBaseName`. If you create a [page bundle](https://gohugo.io/content-management/page-bundles) instead of a regular page, `.TranslationBaseName` will return “Index” instead of the name of the containing folder.
2. It looks like you will need to create a directory in `static/` or `assets/` every time you create a new page. Why not use page bundles instead, and store the image adjacent to the markdown? Less work, easier to maintain, etc.

Question: why do you need to specify the `name` and `identifier` in the menu entry?

---

<div class="post-metadata">

**Author:** ![golodhrim](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/golodhrim/32/16103_2.png) [@golodhrim](https://discourse.gohugo.io/u/golodhrim)\
**Post date:** [January 27, 2022, 1:10am UTC](https://discourse.gohugo.io/t/problem-creating-archetype/36792/3 "2022-01-27T01:10:46Z")

</div>

it is not a bundle i use, the name and identifier are used for a sidemap structure by the toha theme.i just need to create one folder for each category i use.

---

<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:** [January 27, 2022, 1:26am UTC](https://discourse.gohugo.io/t/problem-creating-archetype/36792/4 "2022-01-27T01:26:00Z")

</div>

> [@golodhrim](#):
>
> it is not a bundle i use

I understand that. I was offering a potentially simpler alternative.

> [@golodhrim](#):
>
> the name and identifier are used for a sidemap structure

I understand that. When a menu entry is defined on a page, the `name` property is not required unless you want to use something other than the page title. The `identifier` property is only required if there are duplicate `name` values within the same menu.

In any event, to obtain the values you want, use one or more of the [file variables](https://gohugo.io/variables/files) in conjunction with one or more of these functions:

- [`path.Base`](https://gohugo.io/functions/path.base/)
- [`path.Dir`](https://gohugo.io/functions/path.dir/)
- [`path.Split`](https://gohugo.io/functions/path.split/)
- [`strings.Split`](https://gohugo.io/functions/split/)

---

<div class="post-metadata">

**Author:** ![golodhrim](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/golodhrim/32/16103_2.png) [@golodhrim](https://discourse.gohugo.io/u/golodhrim)\
**Post date:** [January 27, 2022, 6:37pm UTC](https://discourse.gohugo.io/t/problem-creating-archetype/36792/5 "2022-01-27T18:37:44Z")

</div>

@jmooring thanks, you helped to fix my issue, I got a working archetype now that does what I want it to.

possible archetypes for toha-theme:

archetypes/posts.md

```auto
---
title: "{{ replace .TranslationBaseName "-" " " | title }}"
date: {{ .Date }}
# hero: {{path.Join "/images/posts/" (path.Split ( path.Dir .File.Dir ) ).File "image.png" }}
description: Short Description
menu:
  sidebar:
    name: {{ replace .TranslationBaseName "-" " " | title }}
    identifier: {{ lower ((path.Split ( path.Dir .File.Dir ) ).File) }}
    weight: 10
tags: ["Basic", "Multi-lingual"]
categories: ["Basic"]
---

**Insert Lead paragraph here.**

```

and archetypes/notes.md

```auto
---
title: "{{ replace .TranslationBaseName "-" " " | title }}"
weight: 40
menu:
  notes:
    name: {{ replace .TranslationBaseName "-" " " | title }}
    identifier: {{ replace (path.Join .File.Dir .TranslationBaseName) "/" "-" }}
    parent: {{ replace (path.Dir .File.Path) "/" "-" }}
    weight: 10
---

```

---

<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:** [January 29, 2022, 6:37pm UTC](https://discourse.gohugo.io/t/problem-creating-archetype/36792/6 "2022-01-29T18:37:57Z")

</div>

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