Refactoring the views folder

As we did before, let's change the views folder to the following new structure:

views

  • pages/
  • partials/
  1. Remove the default jade files form views folder.
  2. Create a file called layout.html inside the pages folder and place the following code:
          <!DOCTYPE html> 
          <html> 
          <head> 
          </head> 
          <body> 
              {% block content %} 
              {% endblock %} 
          </body> 
          </html> 
    
  3. Create an index.html inside the views/pages folder and place the following code:
          {% extends 'layout.html' %} 
          {% block title %}{% endblock %} 
          {% block content %} 
          <h1>{{ title }}</h1> 
              Welcome to {{ title }} 
          {% endblock %} 
    
  4. Create an error.html page inside the views/pages folder and place the following code:
     {% extends 'layout.html' %} {% block title %}{% endblock %} {% block content %} <div ...

Get Node.js 6.x Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.