Need Help Regarding Params

So I have got someone’s markdown file and below it is.

Code
recommendation:

  - product:

      - badge: Best pick

        details:

          - detail: >-

              <!--StartFragment--

              Overall, this motherboard helps you enhance your system and make you stay one step forward when playing with multiple contenders. Gigabyte is a well-known brand that never compromises on the quality and performance levels. You can enhance your PC build by going for one of the most potent motherboards that are undoubtedly compatible with your i7-10700K.

              <!--EndFragment-->

        pros:

          - pro: PCIe 4.0 slots

          - pro: Smart Fan 5 Features

          - pro: Comes with full SSD thermal guards

Please look at the code and tell me how to access sub-sub params from front-matter.

{{ .Params.recommendation.product.badge }} ->> Best pick
{{ .Params.recommendation.product.details | safeHtml }}
-->
<!--StartFragment--
Overall, this motherboard helps you enhance your system and make you stay one step forward when playing with multiple contenders. Gigabyte is a well-known brand that never compromises on the quality and performance levels. You can enhance your PC build by going for one of the most potent motherboards that are undoubtedly compatible with your i7-10700K.
<!--EndFragment-->
{{ range $key, $param := .Params.recommendation.product.pros }}
  {{ $key }}: {{ $param }}
{{ end }}
 --> pro: PCIe 4.0 slots
     pro: Smart Fan 5 Features
     pro: Comes with full SSD thermal guards

The <!--StartFragment-- is not properly closed, just in case that might have lead you to issues.

I am getting this problem, while the StartFragment is fixed now.

You need to surround any parameter that you collect from your frontmatter with a with in case it is not defined in one or more of your content files. Like this:

{{ with .Params.recommendation.product.badge }}{{ . }}{{ end }}

The {{ . }} is the content of .Params.recommendation.product.badge.

You probably have more than one content file and some of them do not have that frontmatter.

And please don’t post screenshots of code. Post code.

Sorry For Posting the screenshots, But I am getting the same issue. I only have 1 content file, because I am testing on my localhost and then make it live.

Hi,

You need to change both your .md structure and your loop.
md structure
The “product” item nested in "recommendation is redondant. Try this.

    recommendation:
    product:
        - badge: Best pick
          pros:
              - pro: PCIe 4.0 slots
              - pro: Smart Fan 5 Features
              - pro: Comes with full SSD thermal guards
          details: ">-<!--StartFragment-->
                  Overall, this motherboard helps you enhance your system and make you stay one step forward when playing with multiple contenders. Gigabyte is a well-known brand that never compromises on the quality and performance levels. You can enhance your PC build by going for one of the most potent motherboards that are undoubtedly compatible with your i7-10700K. <!--EndFragment-->"

Loop html

<ul>
{{ range .Params.product }}
<li>badge: {{ .badge }}</li>
<li>details: {{ .details | safeHTML }}</li>
<li>
    <ul>
            {{ range .pros }}
            <li>pro: {{ .pro }}</li>
          {{ end }}
    </ul>
</li>
</ul>