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

, ,

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.

:warning: 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:

composer require nielsnicola/kirby-hide-html-comments

Git submodule:

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:

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
// site/config/config.php
return [
‘nielsnicola.hide-html-comments.enabled’ => true, // false = show comments in the DOM
];

Usage

<?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
Packagist: nielsnicola/kirby-hide-html-comments - Packagist