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

145
Views
Is there a better way of handling folder structure in Express Handlebars with views

I'm wondering if there is a better way of rendering my html without having to always have my files named differently. If there's any way handlebars can know I want this file in this folder to be rendered rather than searching everywhere and having same-name conflicts..Any help would be appreciated. Here's an example of code. Thank you!

//Setting up configuration views here //
const hbs = exphbs.create({ helpers, defaultLayout: 'main', extname: '.handlebars' });
app.engine('handlebars', hbs.engine);


//Handlebar files must be named differently //
app.set('views', [
    path.join(__dirname, 'views/corporate'),
    path.join(__dirname, 'views/help-center'),
  ]);
  
app.set('view engine', 'handlebars');

And then my view folder is

enter image description here

And here is an example of one of my routes

const router = require("express").Router();
const config = require("../../lib/config");
const { appUrl } = config;


router.get("/", (req, res) => {
    res.render("corpIndex", {
      appUrl
    });
  });

  module.exports = router;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Well I don’t know if I have the privilege to share this, but it’s available publicly anyway.

I have had a wesbos course (highly recommended if you’re just starting off) and I had this as the starter content.

He uses pug/jade, but if you’re using mcv it will apply and it will be very useful.

If it was a personal project, I won’t care much, however, I used to follow a certain guidelines if I were thinking of any publication, and I may probably use those out of laziness, besides they are good and fit my needs.

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!