# Toggle HTML Comments in Kirby Templates – kirby-hide-html-comments

**URL:** <https://forum.getkirby.com/t/toggle-html-comments-in-kirby-templates-kirby-hide-html-comments/35013>\
**Category:** Plugins\
**Tags:** v3, v4, v5\
**Created:** [November 25, 2025, 9:27pm UTC](https://forum.getkirby.com/t/toggle-html-comments-in-kirby-templates-kirby-hide-html-comments/35013 "2025-11-25T21:27:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nielsnicola](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/nielsnicola/32/16474_2.png) [@nielsnicola](https://forum.getkirby.com/u/nielsnicola)\
**Post date:** [November 25, 2025, 9:27pm UTC](https://forum.getkirby.com/t/toggle-html-comments-in-kirby-templates-kirby-hide-html-comments/35013/1 "2025-11-25T21:27:39Z")

</div>

Hi Kirby devs!

I just released **`kirby-hide-html-comments`** (v1.0.0), a tiny plugin that lets you control whether HTML comments added via the `comment()` helper appear in **any rendered HTML** , both locally and in production.

> ⚠ Note: This plugin **does not remove actual comments from your template files**. It only controls whether `comment()` prints them in the rendered HTML DOM.

* * *

### Installation

**Composer:**

```bash
composer require nielsnicola/kirby-hide-html-comments

```

**Git submodule:**

```bash
git submodule add https://github.com/nielsnicola/kirby-hide-html-comments.git site/plugins/kirby-hide-html-comments

```

**Manual:**  
Download the repository and place it in:

```bash
site/plugins/kirby-hide-html-comments

```

* * *

### Configuration

| Option | Default | Description |
| --- | --- | --- |
| `nielsnicola.hide-html-comments.enabled` | `true` | `true` hides all comments in the DOM; `false` shows them |

```php
// site/config/config.php
return [
‘nielsnicola.hide-html-comments.enabled’ => true, // false = show comments in the DOM
];

```

* * *

### Usage

```php
<?php comment('Hero section starts'); ?>
<div class="hero">
  ...
</div>
<?php comment('Hero section ends'); ?>

```

- `true` → nothing is printed in the DOM

- `false` → prints standard HTML comments in the DOM

* * *

This is a **small, zero-dependency plugin** that lets you easily toggle the visibility of HTML comments in **all rendered HTML output**.

GitHub: [GitHub - nielsnicola/kirby-hide-html-comments: Hide HTML comments in Kirby output](https://github.com/nielsnicola/kirby-hide-html-comments)  
Packagist: [nielsnicola/kirby-hide-html-comments - Packagist](https://packagist.org/packages/nielsnicola/kirby-hide-html-comments)
