# \[Custom output format\] How to prevent whitespace?

**URL:** <https://discourse.gohugo.io/t/custom-output-format-how-to-prevent-whitespace/6116>\
**Category:** support\
**Created:** [April 11, 2017, 12:07pm UTC](https://discourse.gohugo.io/t/custom-output-format-how-to-prevent-whitespace/6116 "2017-04-11T12:07:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jura](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jura/32/13581_2.png) [@Jura](https://discourse.gohugo.io/u/Jura)\
**Post date:** [April 11, 2017, 12:07pm UTC](https://discourse.gohugo.io/t/custom-output-format-how-to-prevent-whitespace/6116/1 "2017-04-11T12:07:10Z")

</div>

I’m using the [custom output format](http://gohugo.io/extras/output-formats/) feature of Hugo 0.20.

Previously, I used a `single.html` file to generate a JSON search index as a `.html` file. That outcome looked like this:

![](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex036/uploads/gohugo/original/2X/2/2c970ea30cf38892d1f5e36c1db1ed227e8c23a8.png)

Now when I create a JSON file with the custom output feature, I get the following:

![](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex036/uploads/gohugo/original/2X/5/5555414d5b21fd8f6617bf1be4068d622fda803a.png)

This unwanted whitespace invalidates my JSON file. Why this happens, I don’t know. I’m using the same Hugo code as before, and even when I add the `-` to [avoid generating blank lines](https://discuss.gohugo.io/t/how-do-i-avoid-the-blank-lines-in-the-generated-html/3157), the same problem happens.

This is what I have in my `single.json` file:

```auto
[
{{- range $index, $page := where .Site.RegularPages "Section" "!=" "" -}}
{{- if and $index (gt $index 0) -}},{{- end -}}
    {{- if (ne $page.Section "") -}}
    {
        "objectID": "{{- $page.UniqueID -}}",
        "url": "{{- $page.RelPermalink -}}",
        "title": "{{- $page.Title -}}",
        "platform": "{{- index $page.Params.categories 0 -}}",
        "content": "{{- $page.Content | plainify -}}"
    }
    {{- end -}}
{{- end -}}
]

```

Thanks!
