Chapter 2Building a Basic Website

In the last chapter, we installed Sinatra and played around with routes and handlers; however, we only ever sent plain strings back to the client, which, let’s face it, has its limits. In most cases, we’ll want to send HTML pages for the browser to show. As usual, Sinatra makes this really easy to achieve.

In this chapter, we’ll look at using views to send HTML to the browser, and start to build a basic website comprising navigable pages. We’ll use templating languages such as ERB (embedded Ruby) and Slim to produce the HTML, and utilize the CSS preprocessor, Sass, to create a stylesheet to make the site look prettier.

Example Website: Songs By Sinatra

The website we’ll be building is called “Songs By Sinatra,” ...

Get Jump Start Sinatra now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.