DEV Community

Aldo Portillo
Aldo Portillo

Posted on • Updated on

TIL: Sinatra Public Folder

Intro

I was attempting to link a style sheet and render an image in my Sinatra project

I went with the ole reliable for linking a stylesheet and rendering an image.

<link rel="stylesheet" type="text/css" href="/stylesheets/style.css" />

<img src="/assets/image_name.jpg" alt="" />
Enter fullscreen mode Exit fullscreen mode

Solution

It didn't work. I got an unknown error on _better_errors and I didn't know what to do. After reading over the Sinatra documentation, I found out that Sinatra looks at a folder named public to store stylesheets and media. This is when I had to modify my folder structure.

On project root, I created a folder named public and added my folders: stylesheets and assets. Images were rendered and stylesheet was linked.

Top comments (0)