Hello guys, please help!
I’m trying to move data from config.toml to desktop.yml - and can’t do it.
Initial .html that picks values from config.toml:
{{ with .Site.Params.feature_list }}
<section class="feature-list section">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="heading">
<h2 class="section-title">{{ .title }}</h2>
</div>
</div>
</div>
{{ range $index, $element := .items }}
{{- if ne (mod $index 2) 1 }}
<div class="row">
<div class="col-md-6 text-center">
<img class="" src="{{ relURL $element.image }}" alt="">
</div>
<div class="col-md-6">
<div class="content mt-100">
<h4 class="section-title">{{ $element.title }}</h4>
<p>{{ $element.text }}</p>
<a href="{{ $element.button_link }}" class="btn btn-round btn-round-sm">{{ $element.button_text }}</a>
</div>
</div>
</div>
{{- else }}
<div class="row">
<div class="col-md-6">
<div class="content mt-100">
<h4 class="section-title">{{ $element.title }}</h4>
<p>{{ $element.text }}</p>
<a href="{{ $element.button_link }}" class="btn btn-round btn-round-sm">{{ $element.button_text }}</a>
</div>
</div>
<div class="col-md-6 text-center">
<img class="" src="{{ relURL $element.image }}" alt="">
</div>
</div>
{{- end }}
{{- end }}
</div>
</section>
{{- end }}
config.toml:
[params.feature_list]
title = "Why Choose Apple Watch"
[[params.feature_list.items]]
image = "images/showcase/showcase-4.png"
title = "Lorem ipsum dolor sit amet."
text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate, sed, assumenda. Tenetur sed esse, voluptas voluptate est veniam numquam, quis magni. Architecto minus suscipit quas, quo harum deserunt consequatur cumque!"
button_link = ""
button_text = "Check Features"
[[params.feature_list.items]]
image = "images/showcase/showcase-3.png"
title = "Lorem ipsum dolor sit amet."
text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate, sed, assumenda. Tenetur sed esse, voluptas voluptate est veniam numquam, quis magni. Architecto minus suscipit quas, quo harum deserunt consequatur cumque!"
button_link = ""
button_text = "Check Features"
my .html that should pick values from data.yml:
{{ with .Site.Data.desktop.feature_list }}
<!-- the same code -->
{{ end }}
my desktop.yml:
feature_list:
- title: 1Why Choose Lorem ipsum
feature_list.items:
- image: img/showcase/pcnc4r.jpg
title: 2Lorem ipsum dolor sit amet.
text: 2Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate, sed, assumenda. Tenetur sed esse, voluptas voluptate est veniam numquam, quis magni. Architecto minus suscipit quas, quo harum deserunt consequatur cumque!
button_link: #
button_text: Check Features
- image: img/showcase/pcnc5box.jpg
title: 3Lorem ipsum dolor sit amet.
text: 3Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate, sed, assumenda. Tenetur sed esse, voluptas voluptate est veniam numquam, quis magni. Architecto minus suscipit quas, quo harum deserunt consequatur cumque!
button_link: #
button_text: Check Features
Currently my code does not show any errors, but does not show any content either.
I think the technology I need is described here: https://novelist.xyz/tech/hugo-data-files/ - but there it works, and in my case it doesn’t. What am I doing wrong?
The template is here: https://themes.gohugo.io/vex-hugo/