Creating json with hugo : how to escape slashes

Hello,

I am creating a json with hugo :

[{{ range $index, $page := .Site.Pages }}
{{ if ne $page.Type "json" }}
{{ if and $index (gt $index 0) }},{{ end }}
{

    "url": "{{ $page.Permalink }}",
    "title": "{{ $page.Title }}",
    "content": "{{ $page.PlainWords  }}"

}{{ end }}{{ end }}]

In my markdownI have this :

* Déterminer l'emplacement de la configuration Maven: `C:\Users\[COMPTE WINDOWS]\.m2\settings.xml`

Anyway to escape the slashes with hugo so it doesn’t invalidate my json?

Thanks

Figured it out, I just changed the style of slash

You can also combile dict with jsonify like this:

Which may make your life easier.

2 Likes

Oh wow thank you so much @bep i’ll give this a go !!

I’ll never get use to the actual main dev helping us out here, it means a lot thanks!

2 Likes

Would using {{- range .Site.RegularPages -}} be the canonical way to do this, for creating JSON search indices?