Chapter 2 Building 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 ...

Get Jump Start Sinatra 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.