API Documentation

Jade-style templates can be compiled and rendered programmatically from JavaScript.

For the modern Pug implementation, the API provides methods for compiling source strings or files and rendering them into HTML.

Compile a template

const pug = require("pug");

const template = pug.compile(`
  h1= title
`);

const html = template({
  title: "Hello"
});

Render a string

const html = pug.render(
  "p Hello #{name}",
  { name: "Alex" }
);

Render a file

const html = pug.renderFile(
  "views/home.pug",
  { title: "Home" }
);

Compile once, render repeatedly

For templates that are rendered many times, compiling once and reusing the resulting function can avoid repeated compilation work. The API also provides file-based compilation and client-side compilation methods.

Important naming note

The original Jade project was renamed Pug. This website documents the historical Jade syntax and terminology; modern projects should consult the current Pug documentation when choosing an actively maintained implementation.

Jade Language © 2026 | About Us | Privacy Policy