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

194
Views
Pass an include parameter in Pug template from ExpressJS?

I'm new to Pug and ExpressJS and can't figure out how to do a simple thing: passing a template path from Express to Pug.

Here's an example of what I have in mind, with the variable named pageContent :

./app.js

app.get('/', function (req, res) {
  res.render('index', {title: 'Some Title', pageContent: 'includes/somePage.html'})
})

./views/index.pug

html
  head 
    include includes/head.html
    title= title
  body
    include includes/header.html
    include #{pageContent}
    include includes/footer.html

Any idea what I am missing ? Thank in advance for your help !

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

0

Please ensure you are using:

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

Also, dynamic import is not allowed yet, so your include can't be variables

about 4 years ago · Juan Pablo Isaza Report

0

Since the pageContent is being passed in via the render function, should this be:

html
  head 
    include includes/head.html
    title= title
  body
    include includes/header.html
    #{pageContent}
    include includes/footer.html
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!