title: Node and handlebars folder structure
body: <p>I would like to change my file and folder structure a bit, I tried looking for solutions already online but didn't find anything simple and I have a feeling this thing should have an simple solution.</p>
  
  <p>I have currently this</p>
  
  <pre><code>var expressHandlebars = require('express-handlebars');
  app.set('views', __dirname + '/views');
  app.engine('hbs', expressHandlebars({extname: 'hbs', defaultLayout: 'main'}));
  </code></pre>
  
  <p>My folder structure is as follows </p>
  
  <pre><code>views
  
  -- frontend
  ---- (doesn't matter, gulp takes care of this for FE).hbs
  
  -- layouts
  ---- main.hbs
  
  -- index.hbs
  </code></pre>
  
  <p>What I wanna archive is to have </p>
  
  <pre><code>views
  
  -- frontend
  ---- (doesn't matter, gulp takes care of this for FE).hbs
  
  -- backend
  ---- views
  ------ index.hbs
  ---- main.hbs
  </code></pre>
  
  <p>Basically, I want when I open my views folder in root to have frontend and then backend folder. Backend folder in root should have main layout and then in folders different partials for specific views.</p>
  
  <p>I can add backend folder without issues which changing</p>
  
  <pre><code>app.set('views', __dirname + '/views');
  </code></pre>
  
  <p>to </p>
  
  <pre><code>app.set('views', __dirname + '/backend');
  </code></pre>
  
  <p><strong>But how do I swap the that layout is in the root of the views folder?</strong> </p>
  
  <p>Just doing this will throw an error because he will look for layout in <code>/backend/layouts/main.hbs</code> and I want it to be in the root.</p>
  
  <p>Also, later I render things by saying <code>res.render('index', data);</code>. Proposed solution should be able to do the same, or at least <code>res.render('views/index', data);</code> because the new views would be in folders.</p>
  
  <p>Any help or tips appreciated.</p>