# Create a Web Page using Express.js and Pug

Published 2022-12-03

This tutorial explains to you how to create a web page using Express.js framework and Pug template. This article provides you with an example as well.

In Express, creating dynamic web pages could be done in several steps, using Pug (Jade got renamed to Pug):

  1. Install express and pug module in Node.js:
npm install express
npm install pug

  1. Create the Pug template in /view and name it template.pug for instance:
    title= title
    h1= message
    h1= "This is my first Express & Pug page !"
    each val in values
      div= " -> "+ val
  1. Create the Express code:
var express = require('express')  
var app = express()  
app.set('view engine', 'pug')
var values = ['John', 'Dan', 'Dana'];
app.get('/', function (req, res) {  
        { title: 'My Custom Title ...', message: 'This is a new text message !', values})
app.listen(2000, function () {  
    console.log('Example app listening on port 2000!')
  1. Run the Express code

and see the result in the browser: