Upgraded from v0.53 to v0.55.6 - breaks schema.org

I’ve just upgraded to the newest Hugo version from v0.53. My project builds successfully and there are no errors, but my schema.org scripts are all rendering incorrectly.

Here’s an example of how my code rendered in v0.53:

<script type="application/ld+json">{
  "@context": "https://schema.org",
  "@type": "Book",
  "name" : "Sapiens: A Brief History of Humankind",
  "author": [    
    {"@type": "Person", "name": "Yuval Noah Harari"}
  "url" : "http://localhost:1313/books/sapiens/"

Here’s how it renders in v0.55.6

<script type="application/ld+json">"{\n \"@context\": \"https://schema.org\",\n \"@type\": \"Book\",\n \"name\" : \"Sapiens: A Brief History of Humankind\",\n \"author\": [\n \n \n {\"@type\": \"Person\", \"name\": \"Yuval Noah Harari\"\n }],\n \"url\" : \"http://localhost:1313/books/sapiens/\"}"</script>

My code:

layouts > book > single.html

<script type="application/ld+json">{{partial "schema-book.html" . }}</script>

layouts > partials > schema-book.html

  "@context": "https://schema.org",
  "@type": "Book",
  "name" : {{.Title | jsonify}},
  "author": [
  {{range $i, $e := .Params.authors}}
    {{if $i}}, {{end}}
    {"@type": "Person", "name": {{$e | jsonify}}
  "url" : {{.Permalink | jsonify}}

It also renders my other schema files incorrectly. They are of a similar structure, but also contain the following:

"{{$content := print "<p>" (partial "description.html" .) "</p>"}}
{{$content | safeHTML}}"

which shows up as:

    "description": "\x3cp\Product is is available in all stores.\x3c\/p\x3e"

Before it was:

    "description": "Product is is available in all stores."

Have you tried safeJS ?

<script type="application/ld+json">{{partial "schema-book.html" . | safeJS }}</script>

Just ran a few tests on previous version, and it seems before .55, safeJS was not needed when outputting a jsonify.ed object inside a <script> tag.

Now it is, I’ve never been too certain about when to use safeJS except for testing the output, so this may be for the best.

Would be curious to know if anything else is affected.

@regis Many thanks for helping out, and sorry for not responding earlier.

Adding safeJS solves the problem. I haven’t marked this issue as solved as hopefully someone can join in, and provide some more context as to why safeJS is now required.

In the meantime, I’ve reverted back to v0.53 as I haven’t had time to check if anything else is affected. The only reason I caught this issue was due to errors in Google Webmaster Tools.