Problem creating archetype

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

---
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.**

Initial comments:

  1. Use .File.ContentBaseName instead of .TranslationBaseName. If you create a page bundle 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?

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.

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

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 in conjunction with one or more of these functions:

1 Like

@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

---
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

---
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
---

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