Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
Pug - unable to get past step 1 of a boilerplate

total noob question but I cannot find any solutions to this sorry so last resort is to ask here.

I am trying to learn pug. Have created a boilerplate project and unable to render index page. Ive searched and read as much as I can but all I get is 'Error parsing body of the with expression' error. The index.js looks as simple as follows but stopping me in my tracks:

var express = require('express');
var router = express.Router();

// GET home page. 
router.get('/', (req, res) => {
  res.render('index', { title: 'Express' });
});

module.exports = router;

if anyone can provide a one liner to point me in the right direction to resolve this and keep rolling on my pug and nodejs journey I'd really appreciate it. Pug is appearing very difficult at this stage despite all the raving about it :/

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I have checked one of my old projects. You can try something like this:

Install pug:

$ npm install pug --save

Then set up the app:

const express = require('express')
const app = express()
const port = 3000

// you don’t have to specify the engine or load the template engine module in your app; 
// Express loads the module internally, as shown below (for the above example).

app.set('view engine', 'pug')

// views, the directory where the template files are located
// This defaults to the views directory in the application root directory.

app.set('views', './views')


app.get('/', (req, res) => {
  res.render('index', { title: 'Hey', message: 'Hello there!' })
})

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})

Example pug file:

html
  head
    title= title
  body
    h1= message

Using template engines

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!