Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

147
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda