Can't range through front matter array

Hello.

I’ve checked out the docs and the community but I can’t seem to range through an array I have in my front matter.

Front Matter:

---
title: "Business Development Manager*in DACH SaaS (m/w/d)"
draft: false
profile: ["profile 1", "profile 2"]
tasks: ["tasks 1", "tasks 2"]
---

Template Code:

{{ define "main" }}
  {{ if site.Data.general.profile_and_tasks.enable }}
		{{ with site.Data.general.profile_and_tasks }}
			<section class="section">
				<div class="container">
					<div class="row px-3">
						<div class="col-lg-6 text-center">
							<h2 class="section-title">{{ .title_left | markdownify }}</h2>
							<hr>
							<h4 class="section-subtitle">{{ .subtitle_left | markdownify }}</h4>
							{{ range .Params.profile }}
								<ul class="mx-auto fa-ul">
									<li class="mb-1 bullet_point">
										<span class="fa-li">
											<i class="fa-solid fa-circle-check color_primary"></i>
										</span>
										<p>{{ . }}</p>
									</li>
								</ul>
							{{ end }}
						</div>
						
						<div class="col-lg-6 text-center">
							<h2 class="section-title">{{ .title_right | markdownify }}</h2>
							<hr>
							<h4 class="section-subtitle">{{ .subtitle_right | markdownify }}</h4>
							{{ range .Params.tasks }}
								<ul class="mx-auto fa-ul">
									<li class="mb-1 bullet_point">
										<span class="fa-li">
											<i class="fa-solid fa-circle-check color_primary"></i>
										</span>
										<p>{{ . }}</p>
									</li>
								</ul>
							{{ end }}
						</div>
					</div>
				</div>
			</section>
		{{ end }}
  {{ end }}
{{ end }}

What seems to be the issue?

Thanks.

You changed the context (the dot) from the parent (presumably the page) to site.Data…

You can get back to the root context with:

{{ range $.Params.profile }}

https://gohugo.io/functions/with/

1 Like

Aaaaah, the context. Silly mistake. Thanks. :grinning:

1 Like

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