# Minify's \`keepComments\` option doesn't work?

**URL:** <https://discourse.gohugo.io/t/minifys-keepcomments-option-doesnt-work/34555>\
**Category:** support\
**Created:** [September 2, 2021, 4:20pm UTC](https://discourse.gohugo.io/t/minifys-keepcomments-option-doesnt-work/34555 "2021-09-02T16:20:01Z")\
**Posts on this page:** 3\
**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:** [September 2, 2021, 4:20pm UTC](https://discourse.gohugo.io/t/minifys-keepcomments-option-doesnt-work/34555/1 "2021-09-02T16:20:01Z")

</div>

Following the [documentation](https://gohugo.io/getting-started/configuration/#configure-minify), I’ve added this to my `config.toml` file:

```auto
# Minification options
[minify]
    [minify.tdewolff]
        [minify.tdewolff.html]
            keepComments = true

```

But this does not keep the comments in the HTML rendered by Hugo. Instead those comments are simply removed, regardless of whether `keepComments` is `true` or `false`.

The minify library that Hugo uses doesn’t list a `keepComments` option ([source](https://github.com/tdewolff/minify#html)). Is this feature perhaps removed?

* * *

```nohighlight
hugo v0.87.0-B0C541E4+extended windows/amd64 BuildDate=2021-08-03T10:57:28Z VendorInfo=gohugoio

```

---

<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:** [September 2, 2021, 4:33pm UTC](https://discourse.gohugo.io/t/minifys-keepcomments-option-doesnt-work/34555/2 "2021-09-02T16:33:33Z")

</div>

Solved; I found that outputting HTML comments require special syntax with `safeHTML` as explained [here](https://discourse.gohugo.io/t/how-to-add-comments-in-a-template/75/8).

If I use `safeHTML` and `keepComments` together, then it does work.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [September 4, 2021, 4:34pm UTC](https://discourse.gohugo.io/t/minifys-keepcomments-option-doesnt-work/34555/3 "2021-09-04T16:34:03Z")

</div>

Closed on September 4, 2021, 4:34pm UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
