Backslash added to my JSON Structured Data

Hello;

I switched recnetly to Hugo 55, after long use of 48 version.

I have problems with the generated JSON code, back slashes are added to URL, so it makes structured data control failed.

Using the same code in HTML regions, shows the url without escape back slash

Someone have any idea?
{
@context”: “http://schema.org”,
@type”: “Article”,
“url”: “{{ .Permalink | safeHTML}}”,
“headline”: " {{ .Params.Title }}",
“image”: “{{ .Params.banner }}”,
“keywords”: “{{ .Site.Params.defaultKeywords }}”,
“datePublished”: “{{ .Params.date }}”,
“articleSection”: “Lifestyle”,
“creator”: “HTS”,
“author”: “HTS”,
“articleBody”: “{{ .Summary }}”,
“mainEntityOfPage”: “True”,
“contactPoint”: [{
@type”: “ContactPoint”,
“telephone”: “{{ .Site.Params.phone | safeHTML}}”,
“contactType”: “reservations”
}
}

Regards

Try:

"url": {{ .Permalink | jsonify | safeJS }},

Hi, i tried this, the issue persists

Try removing the " marks. There is another thread about a similar issue here:

In short, it seems that since the code is already inside a <script> tag, Hugo outputs it accordingly.

I think that the solution is to use such code

{{ dict “url” .Permalink }},

But how to do is with all a huge data . Used like that it print :

{“url”:“https://www.hairtransplant.fr/blog/2019/06/15/proteger-cheveux-soleil/”},

Regards

1 Like