Pug was formerly called Jade until it’s version 2.0 was released in 2015.
Let’s make a basic pug template using express.js:
Prerequisite: Basic working knowledge of express is required.
Step 1: Make an empty project folder. In command prompt / terminal, run npm init to intialize package.json file:
npm init -y
-y flag is for default settings in package.json.
Step 2: Install express and pug. We will directly install ‘express’ package rather than generating our express app with ‘express-generator’ for simplicity reasons. You can optionally install nodemon for hot reloading.
npm install express pug
Our final directory structure will look like this:
Step 4: Setting up a basic express app. In Index.js:
Step 5: In index.pug file:
You can read basics of pug syntax here.
Step 6: In terminal start the application. Run nodemon command if we have installed it previously, or just simply use node.
node index.js or nodemon index.js
In browser on localhost 3000 port, we get the below rendered template:
- PugJS Basic Tags
- Sails.js Basics and Installation
- Introduction and Installation of Git
- Introduction and Installation of Heroku CLI on Windows machine
- Laravel | Installation and Configuration
- Materialize | Introduction and Installation
- p5.js | SoundFile Object Installation and Methods
- Slim Framework | Installation and Configuration
- XQuery | Installation and Example
- Installation and Configuration Symfony Framework
- Svelte | Introduction and Installation
- CakePHP Framework | Installation and Configuration
- Introduction and Installation process of Gulp
- Material UI Introduction and Installation for React
- Ant Design Introduction and Installation for Angular
- Installation of Node.js on Windows
- Angular 7 | Installation
- Installation of Node.js on Linux
- Vue.js | Introduction & Installation
- Basics of the Blockchain and its various applications
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.