In most situations, when building a web application or website like that of the previous example, you won't just serve HTML files. Although some applications use this approach, where a single HTML is served, and then the JavaScript on the page interacts with the server through APIs to customize the page (commonly referred to as a Single Page App) which would be common in an AngularJS application, most web applications will customize the content served before is sent. This is commonly known as server-side rendering. There has been a lot of innovation in this area recently from client-side libraries such as React, where some of the page is rendered server-side and some on the client. These have been dubbed UniversalJS or Isomorphic JavaScript apps. Those concepts are worth knowing about, but are beyond the scope of this book.
What we will look at in this section is how to do server-side rendering, commonly called templating. In hapi, for templating support, much...