Let try to clarify a few more things.
I’m building a text card that I want to use on multiple occasions through my Hugo website.
Situation 1
On a list template where I’m using a range function that loops over my posts. And I want to link the card to the post.
{{ range $index, $page := where .Data.Pages.ByWeight "Type" "partners" }}
{{ partial "components/cards/text.html" . }}
{{ end }}
In partial i’m using:
{{ $link := .RelPermalink }}
Situation 2
On a list template where I’m using a range function that loops over my posts. And I want to link to a custom param.
{{ range $index, $page := where .Data.Pages.ByWeight "Type" "partners" }}
{{ partial "components/cards/text.html" . }}
{{ end }}
In partial i’m using:
{{ with .Params.link }}
{{ $link := . }}
{{ end }}
Situation 3
In a template where I’m looping over a range from a front-matter template.
Front matter
products:
- title: Debiteurenbeheer
link: debiteurenbeheer
- title: Financiering
link: financiering
{{ with .Params.products}}
{{ range $index, $element := .}}
{{ partial "components/cards/text.html" . }}
{{ end }}
{{ end }}
In partial i’m using:
{{ with .link }}
{{ $link := . }}
{{ end }}
Problem
The problem occurred when the card/text partial called on a page without font-matter range. I’m just totally lost on how to make this work.
Current partials/components/cards/text.html code
{{ $link := .RelPermalink }}
{{ with .Params.link }}
{{ $link := . }}
{{ end }}
{{ with .link }}
{{ $link := . }}
{{ end }}
<a href="{{ $link }}" >....</a>