user1189352 user1189352 - 11 months ago 68
Node.js Question

How do I render a HTML file in a subfolder?

Within my "views" folder, i have another folder inside called "partials" that has other html files i'd like to render.

I thought it'd be self explanatory but searching through google I can't find the answer to this, but I'd like to render a file within the subdirectory as well.

I'm sure the answer is rather simple but I can't seem to find it..

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'html');
app.engine('html', require('ejs').renderFile);

var router = express.Router();

//This Works
router.get('/', function(req, res, next) {

//This Works
router.get('/about', function(req, res, next) {

//This Does NOT Work, How do I get this to work?
router.get('/partials/navbar', function(req, res, next) {

Answer Source

Maybe just remove the first / from res.render('/partials/navbar')