Link to a specific data/$name.yaml in an archetype

Hi,

i want to create an archetype to create sites for customers by an archetype. I also want to fill this Customersites with data.
So i created an archetype in which i load a partial HTML file, named archetypes/customers.md:

---
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
---
{{ range $.Site.Data.customers }}
{{ partial "customersite.html" . }}
{{ end }}

With this i would load all *.yaml files in /data/customers.
How can i load contents of an specific .yaml?

This *.yaml has the same name as the *.md file, which i create with hugo new customers/example.md (in this case i would like to load the /data/customers/example.yaml file)

Thank you :slight_smile:

archetypes/customers.md

{{ $data := index site.Data .Type .File.ContentBaseName }}

This will work if you:

hugo new customers/foo.md

But it will not work with leaf bundles:

hugo new customers/foo/index.md  # FAILS

From the documentation:

.File.ContentBaseName

is a either TranslationBaseName or name of containing folder if file is a leaf bundle.

.File.ContentBaseName works as expected when used in a template, but fails when used in an archetype.

Is there a bug for that?

@bep Investigating now… will create one.

Thank You!
With this index thing i can do exactly what i want.

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