Hello!
I am trying to create a sort of sub- Title and Description list in hugo.
So you would feed it a yaml Dictionary basically and it will write them all out on the page.
right now I’ve tried creating the yaml scaffolding like this:
description:
subtitle: SubTitle
subdescription: SubDesc
I tried testing this, by referencing them in the html like this:
{{ .description.subtitle }}
{{ .description.subdescription }}
My logic didnt workout, if i just use this scaffolding:
description: Some random data
{{ .description }}
The description seems to come through well,
what is the issue?
Also are you able to loop through the dictionary in hugo aswell?
zwbetz
March 27, 2020, 4:30am
2
Hi there.
You have multiple issues:
YAML is indentation-sensitive, so your dict keys need 2 spaces
The front matter description
is a reserved word in Hugo, so try something else, like my_ description
To access custom front matter params, you need to use .Params
So…
Given this front matter
---
title: My Page
my_description:
subtitle: SubTitle
subdescription: SubDesc
---
And this template logic
{{ .Params.my_description.subtitle }}
{{ .Params.my_description.subdescription }}
You get this output
SubTitle
SubDesc
1 Like
system
Closed
March 29, 2020, 9:59am
4
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.