Hugo 0.55.* breaks structured data rendering

Found my own fix, though it’s a rather painful workaround.

I now have two partial templates: the first provides the actual structured data:

{
    "@context": "http://schema.org",
    "@type": "WebSite",
    "name": "{{ $.Site.Title }}",
    {{- with site.Params.alternatePageName }}"alternateName": "{{ . }}",{{- end }}
    "url": "{{ $.Site.BaseURL }}"
}

The second invokes the first and uses safeJS on the contents:

<script type="application/ld+json">
{{ partial "seo/website" . | safeJS }}
</script>

This at least gets me back to working, though it dramatically increases the number of partials I have to have lying around.

5 Likes