Kirby With Pug Templates & Phug

I have seen many programmers mention Pug as a ‘templating language’, as if it were similar to Twig or Blade. Pug is actually an HTML preprocessor - much like LESS/SASS for CSS, and Coffeescript/Typescript to JS.

I have started to use Pug to write my templates and snippets, instead of HTML, but I’m finding the process cumbersome, as I have to compile the Pug files into HTML before Kirby is able to use them. There are, however, a few Pug compilers/parsers written in PHP - such as Phug. I was wondering, therefore, whether there is a way to add the Phug compiler as a plugin directly into Kirby - i.e., as a pre-processor to all templates and snippets, enabling me to save the “.pug” files directly into my ‘templates’ and ‘snippets’ directories.

I’ve had a quick look at the online docs, but cannot seem to find specific instructions… Can someone provide some guidance? Is this possible?..

I’ve had a go at Pug in the past (for static html sites), and honestly, i gave up. I just created more problems than it solved.

Can you not just install via Composer and add it that way?

Looks like Pug is what was formerly called Jade, there is aKirby Jade plugin that might serve as a starting point.

Then know that if you use a project containing “jade” in its name, it’s probably obsolete as jade is the old name of pug, for example packages kylekatarnls/jade-php, ronan-gloo/jadephp, opendena/jade.php, jumplink/jade.php, dz0ny/jade.php and everzet/jade are all no longer maintained projects that fork the same origin, they are not pugjs 2 compliant and miss a lot of pug features. The most up-to-date project that replace them all is pug-php/pug. In its version 2 it still use the same original engine. Same goes for talesoft/tale-jade replaced with talesoft/tale-pug and its version 2 will also use Phug.
talesoft/tale-pug and pug-php/pug are the most used Pug ports and are actively maintained. By using the last version of these projects, you will therefore automatically migrate to the Phug engine and as contributors of these both projects are now gather in the Phug project and will develop Phug in priority, you will benefit from the best possible support. (

Fyi, I just published my solution

seems like that is just what i was looking for, presuming it works with kirby3.
will give it a spin.

@kosmar No, that plugin won’t work with Kirby 3. For Kirby 3, there are plugins for Blade, Handlebars and Twig.

thx @texnixe

i just tested using plain pugjs with php code inside – and codekit compiles it and renames to .php

that seems to do the trick anyway.