Define the {{ partial "xxx" . }} filename via front matter

Hi, - Trying to add a Front Matter defined partial to a HTML template.

Read through all the dots but still struggling…

This is what I’m trying to do in concept (but obviously this doesn’t work):
{{ partial “{{ .Params.partial_file_difined_via_front_matter }}” . }}

How can I use the same HTML template and still insert a different partial or shortcode into the HTML template?

Thanks,

You can do the following:

In _default/single.html or whatever template you need

{{ with .Params.partialName }}
{{ $name := . }}
{{ partial $name . }}
{{ end }}

Sample front matter parameter

partialName = "test.html"
2 Likes

Worked like a charm!! Thanks very much :slight_smile:

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