Open In App

Pug View Engine Installation

Pug, once known as Jade, makes writing HTML codes e­asy for NodeJS and web browsers. It’s cle­ar syntax and handy features spee­d up web work and keep things simple­. This quick guide will go over what you nee­d to use Pug, how to install it, and what it does, and will give you cle­ar steps along with examples to cre­ate your first application using Pug.

Prerequisites :

Features of Pug :

Steps to Create Install Pug View Engine:

Step 1: This command will help to install pug and pug cli in the machine.



npm install pug
npm install pug-cli -g

Step 2: Create a Pug Template: Now lets create a new pug file with the name of index.pug with some code in it

doctype html
html(lang="en")
head
title Pug Example
body
h1 Welcome to Pug World
p This is a simple Pug page.

Step 3: Compile the Pug file to HTML: This command will help to compile pug into html file and there after it will can be run into the browser to see output.



pug index.pug

Output (index.html):

<!DOCTYPE html>
<html lang="en">
<head>
<title>Pug Example</title>
</head>
<body>
<h1>Welcome to Pug World</h1>
<p>This is a simple Pug page.</p>
</body>
</html>

Output:

creating a pug project

Article Tags :