Friday, 19 May 2017

Templating from static HTML pages, best practice?

First time building a Node.js backend using Express from some static HTML pages I was given. I'm using jade/pug to template my site, but since I've never done this before, I'm not really familiar with how this is generally done.

My site is very simple, it has a front page, 2 user panel pages, and a signup page. Users login via a modal on the front page. Many example/guides I have read start with a skeleton layout that looks something like:

doctype html
html(lang='en')
  head
    title= title
    link(href='stylesheets/style.css', rel='stylesheet')
  body
    block content

Given the simplicity of my site, I was going to make all my views extend the template above, and then have separate 'partial' views for my footer, navbars, header, etc. Then use includes to add them to my 'main' views. Something like:

extends layout

include header
include topnav
block content
  <!-- specific page content -->
include foot

Is this the common way of doing things? or am I completely off?



via Phil O'kelly

No comments:

Post a Comment