How to add pug engine in Express.js ? Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Express is a small framework that sits on top of Node.js web server functionality to simplify its APIs and add helpful new features. It makes it easier to organize your application’s functionality with middleware and routing; it adds helpful utilities to Node.js’s HTTP objects; it facilitates the rendering of dynamic HTTP objects. In this article, we are going to learn how to use the pug engine in Express.js. Let us first start by creating a node.js project named pug. For that let's create the folder named pug and run the command npm init in it.  Now that we have set up our project, let's now install the necessary packages. First, we install Express.js, to install we will run the command: npm install express --save Next, we will install pug. Run the following command to install: npm install pug --save Now to set pug as the view engine, run the command: express --pug or express --view=pug Now run the project by using the command: npm start Example: You can edit the content of the file index.pug to change the content of the screen. HTML extends layout block content h1= title p Welcome to #{title} p Let's start using Pug Output:  Now you are ready to start using the pug template engine in express in your projects. Comment More infoAdvertise with us Next Article How to add pug engine in Express.js ? A aayushmohansinha Follow Improve Article Tags : Technical Scripter Web Technologies Node.js Express.js Technical Scripter 2022 NodeJS-Questions +2 More Similar Reads How to use Template Engines in Express JS ? Express.js is a popular web framework for Node.js that simplifies the process of building web applications. One of the key features of Express is its ability to integrate with template engines, allowing developers to dynamically generate HTML pages with data from their server. In this article, we'll 3 min read How to Configure multiple View Engines in Express.js ? View engines present in web application framework are basically the template engines that allow us to embed dynamic content into the web pages, render them on the server, and send them to the client. With the help of these, we can serve dynamic data, and utilise the template inheritance properties t 3 min read Express.js app.engine() Function The app.engine() function is used to register the given template engine callback as ext. By default the Express itself will require() the engine based on the file extension. Syntax:app.engine(ext, callback)Parameters: The ext parameter is the extension type like ejs, hbs, etc and callback is the fun 2 min read How to run pug View Engine using Express? Pug or Jade is the template engine for NodeJS and browsers that are used for the process of developing dynamic HTML content. This template engine uses the indentation-based syntax like Python to generate the HTML markup, which makes it simpler to write and also to maintain the code. If we want to ru 2 min read How to create Lists in Pug View Engine ? Pug is a template engine for NodeJS and browsers to render dynamic reusable content. At compile time, the template engine compiles our Pug template code to HTML. Pug has many powerful features like conditions, loops, includes, and mixins using which we can render HTML code based on user input or ref 4 min read Like