Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Express Basics Using Templates with Express Using Pug in Your Express App

Can't load page - don't know why?

const express = require('express'); const app = express();

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

app.get('/', (req, res) => { res.render('index') });

app.listen(5500, () => { console.log('Its up and running') });

3 Answers

Hi Isabelle,

my error was that my 'views' folder was misplaced. It should be in the same directory as node modules, i.e. on the same level. Hope you worked it out, but I am leaving my comment here in case anybody else makes the same mistake as me:) Happy coding and debugging!

Justin White
Justin White
8,765 Points

Thank you Andrea that solved my problem!

Frank Kynard
Frank Kynard
6,958 Points

This helped me as well thanks so much!!!

Hi Isabelle

From what you have provided, everything seems to be correct so here is a few things for you to double check:

  1. You have both express and pug installed as dependencies
  2. You are running the express server and accessing through the port 5500
  3. You are indenting correctly in your pug template
  4. There are no errors in your browser console and/or node console
  5. you have put your index.pug file in the "views" directory, with the correct spelling

useful info

Hope this helps!

Make sure to update to pug@2.0.1 to solve the issue