# JSON-LD	 Bad escape sequence in string. \\x26 and \\x27

**URL:** <https://discourse.gohugo.io/t/json-ld-bad-escape-sequence-in-string-x26-and-x27/20011>\
**Category:** Uncategorized\
**Created:** [August 5, 2019, 9:22am UTC](https://discourse.gohugo.io/t/json-ld-bad-escape-sequence-in-string-x26-and-x27/20011 "2019-08-05T09:22:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mickel1982](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mickel1982](https://discourse.gohugo.io/u/mickel1982)\
**Post date:** [August 5, 2019, 9:22am UTC](https://discourse.gohugo.io/t/json-ld-bad-escape-sequence-in-string-x26-and-x27/20011/1 "2019-08-05T09:22:15Z")

</div>

I’m getting the following error: **JSON-LD Bad escape sequence in string.**

I noticed that **’** becomes **\x27** (e.g., doesn\x27t work) and **&** becomes **\x26** (e.g., Windows \x26 Linux).

Example front matter:

```
---
title: "My Title"
description: "Here's how to fix this problem."
image: "images/image.png"
date: 2017-11-06
---

```

site-schema.html:

```
{{- if .IsHome -}}
<script type="application/ld+json">
{
"@context":"https://schema.org",
"@type":"WebSite",
"name":"{{ .Site.Params.name }}",
"url":"{{ .Site.BaseURL }}",
"image":"{{ .Site.Params.image }}"
}}
</script>
{{- end }}
{{- if .IsPage -}}
<script type="application/ld+json">
{
"@context":"https://schema.org",
"@type":"TechArticle",
"name":"{{ .Title }}",
"headline":"{{ .Title }}",
"description":"{{ .Description }}",
"url":"{{ .Permalink }}",
"image":"{{ .Site.BaseURL }}{{ .Params.image }}",
"author":{
"@type":"Person",
"name":"{{ .Site.Params.author }}"},
"publisher":{
"@type":"Organization",
"name":"{{ .Site.Params.name }}",
"logo":{
"@type":"ImageObject",
"url":"{{ .Site.Params.logo }}"}},
"mainEntityOfPage": {
"@type":"WebPage",
"@id":"{{ .Permalink }}"},  
{{ if not .Date.IsZero -}}"datePublished":"{{ .Date.Format "2006-01-02" | safeHTML }}",{{- end }}
{{ with .Lastmod -}}"dateModified":"{{ .Format "2006-01-02" | safeHTML }}"{{- end }}
},}
</script>
{{- end }}

```

How can I fix this?

---

<div class="post-metadata">

**Author:** ![ju52](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/ju52/32/6749_2.png) [@ju52](https://discourse.gohugo.io/u/ju52)\
**Post date:** [August 5, 2019, 10:11am UTC](https://discourse.gohugo.io/t/json-ld-bad-escape-sequence-in-string-x26-and-x27/20011/2 "2019-08-05T10:11:26Z")

</div>

> **[safeJS](https://gohugo.io/functions/safejs/)**
>
> Declares the provided string as a known safe JavaScript string.

There are 3 functions safeCSS, safeHTML and safeJS

---

<div class="post-metadata">

**Author:** ![peaceiris](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/peaceiris/32/7358_2.png) [@peaceiris](https://discourse.gohugo.io/u/peaceiris)\
**Post date:** [August 5, 2019, 10:15am UTC](https://discourse.gohugo.io/t/json-ld-bad-escape-sequence-in-string-x26-and-x27/20011/3 "2019-08-05T10:15:59Z")

</div>

Please try to remove `""`

```diff
- "description": "{{ .Description }}",
+ "description": {{ .Description }},

```

---

<div class="post-metadata">

**Author:** ![mickel1982](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mickel1982](https://discourse.gohugo.io/u/mickel1982)\
**Post date:** [August 5, 2019, 2:11pm UTC](https://discourse.gohugo.io/t/json-ld-bad-escape-sequence-in-string-x26-and-x27/20011/4 "2019-08-05T14:11:09Z")

</div>

Thank you. Your solution worked.

---

<div class="post-metadata">

**Author:** ![saper](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/saper/32/10349_2.png) [@saper](https://discourse.gohugo.io/u/saper)\
**Post date:** [January 23, 2020, 8:24pm UTC](https://discourse.gohugo.io/t/json-ld-bad-escape-sequence-in-string-x26-and-x27/20011/5 "2020-01-23T20:24:36Z")

</div>

> [@peaceiris](#):
>
> - “description”: “{{ .Description }}”, + “description”: {{ .Description }},

It works, but why? What to do if we need to concatenate strings?

---

<div class="post-metadata">

**Author:** ![moorereason](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/moorereason/32/592_2.png) [@moorereason](https://discourse.gohugo.io/u/moorereason)\
**Post date:** [January 23, 2020, 10:26pm UTC](https://discourse.gohugo.io/t/json-ld-bad-escape-sequence-in-string-x26-and-x27/20011/6 "2020-01-23T22:26:31Z")

</div>

The template engine will quote the result of `{{ .Description }}` for you. To concat strings, you should be able to do:

```auto
"description": {{ printf "%s%s" .Description .SomethingElse }},

```

---

<div class="post-metadata">

**Author:** ![divinerites](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/divinerites/32/12625_2.png) [@divinerites](https://discourse.gohugo.io/u/divinerites)\
**Post date:** [January 23, 2020, 11:15pm UTC](https://discourse.gohugo.io/t/json-ld-bad-escape-sequence-in-string-x26-and-x27/20011/7 "2020-01-23T23:15:37Z")

</div>

see also [Hugo 0.55.\* breaks structured data rendering](https://discourse.gohugo.io/t/hugo-0-55-breaks-structured-data-rendering/18316/2) which is cleaner imho
