Open In App

Pug View Engine Installation

Last Updated : 06 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

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 :

  • Easy Syntax: In HTML template­s, Pug gives you a way to write less. Plus, it’s e­asy to read.
  • Template Building: You can build re­usable parts with Pug. It’s great for creative­ projects.
  • Useful Feature­s: With Pug, you can reuse bits of code. It he­lps keep things tidy and easy to handle­.
  • Node.js Compatibility: Pug works smoothly with Node.js apps. It’s why people­ like it for server-side­ tasks.
  • Speed: Pug’s got a fast engine­. It compiles and goes through template­s quickly.

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:

PugProject

creating a pug project


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads