Build code as a `dict` and `jsonify` it

Could someone guide me on how to build the code below as a dict in Hugo and then output it with jsonify? Creating the second list item is where I am getting lost.

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "BreadcrumbList",
  "itemListElement": [
    {
      "@type": "ListItem",
      "position": 1,
      "item": {
        "@id": {{ site.Home.Permalink }},
        "name": "{{ site.Title }}"
      }
    },
    {
      "@type": "ListItem",
      "position": 2,
      "item": {
        "@id": {{ .FirstSection.Permalink }},
        "name": "{{ .FirstSection.LinkTitle }}"
      }
    }
  ]
}
</script>
{{ $m := dict
  "@context" "https://schema.org"
  "@type" "BreadcrumbList"
  "itemListElement" (slice
    (dict
      "@type" "ListItem"
      "position" 1
      "item" (dict
        "@id" site.Home.Permalink
        "name" site.Title
      )
    )
    (dict
      "@type" "ListItem"
      "position" 2
      "item" (dict
        "@id" .FirstSection.Permalink
        "name" .FirstSection.LinkTitle
      )
    )
  )
}}

<pre>
{{ jsonify (dict "indent" "  ") $m }}
</pre>
2 Likes

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