Pug: HTML template engine for Node.js
Whitespace-sensitive template engine compiling to HTML for Node.js with Haml-inspired syntax.
Learn more about Pug
Pug is a template engine that transforms indentation-based markup into HTML output. It uses whitespace and indentation to define document structure, eliminating the need for closing tags while supporting JavaScript expressions, conditionals, and loops. The engine compiles templates into JavaScript functions that can be executed with data to generate HTML. Pug is commonly used in web applications for server-side rendering, static site generation, and client-side templating.
Whitespace Syntax
Uses indentation and whitespace to define HTML structure instead of closing tags. This approach reduces markup verbosity and enforces consistent formatting.
JavaScript Integration
Supports embedded JavaScript expressions, conditionals, and loops directly within templates. Variables and functions can be passed to templates during compilation.
Modular Architecture
Built with separate packages for lexing, parsing, code generation, and runtime execution. This modular design allows for customization and integration with different build systems.
const pug = require('pug');
// Compile a template function
const template = pug.compile('p Hello #{name}!');
const html = template({ name: 'World' });
// Or render directly
const html2 = pug.render('p Hello #{name}!', { name: 'World' });
console.log(html); // <p>Hello World!</p>Top in Developer Tools
Related Repositories
Discover similar tools and frameworks used by developers
Fastfetch
High-performance CLI system information display written in C.
Playwright MCP
Accessibility tree-based browser automation for LLMs.
nvm
Per-user Node.js version manager for switching between installed versions via command line on POSIX-compliant shells.
StatsD
UDP/TCP metrics collector with pluggable backend support.
spdlog
Fast C++ logging with flexible sinks and fmt formatting.
Related Reading
Guides and comparisons from the Greptile content library
27 Code Quality Tools that Catch Bugs [2026 Review]
The best code quality tools that catch bugs, security vulnerabilities, and runtime errors, sorted by language, with type, noise level, cost, and who each one is for.
Flaky Tests: What Is a Flaky Test and How Do You Manage Them?
What flaky tests are, what causes them, how to detect them, and 12 ways to fix them. Plus why end-to-end tests are more prone to flakiness, and how seeing what actually happened during a run helps you tell a test problem from a code problem.
What is agentic coding? Benefits, risks, and best tools to consider
What engineering leaders need to know about agentic coding: how it differs from AI coding and vibe coding, how it works, the benefits and risks, and the tools worth evaluating.
Best CodeRabbit Alternatives for Smarter AI Code Reviews in 2026
7 powerful CodeRabbit alternatives ranked by real dev teams. Feature comparison, pricing analysis, and honest reviews to find your perfect AI code reviewer.