Koa-pug is a Pug (formerly Jade) template engine middleware for Koa (v1 and v2) JavaScript web frameworks. Current stable version is 5.1.1, released in 2019, with infrequent updates (last commit 2019). It integrates Pug templates into Koa by binding ctx.render() and supports custom view paths, global helpers via helperPath, and standalone rendering. Key differentiators: seamless Koa integration, helper auto-loading from directories, and Pug@3 support. Alternatives like @ladjs/koa-pug-view are more actively maintained.
npm install koa-pugVerified import paths — ran on the pinned version, not inferred.
Sets up a Koa server with Pug template rendering using koa-pug middleware.
Consider using @ladjs/koa-pug-view for active support.
Upgrade Node.js to >=10 and install Pug@3.
Pass { app: app } in options or call pug.use(app).Use PascalCase or camelCase in filenames to avoid naming conflicts.
new Pug({ app: app }) or pug.use(app);npm install pug --save
Ensure viewPath is correct (defaults to process.cwd()) and template exists.