Peter Boomsma
Peter Boomsma

Reputation: 9808

Compass/Middleman image-url isn't working

I'm currently working with Middleman to build up a new page, but now the image-url helper doesn't seem to be working.

In my config.rb I have:

#Use relative URLs   
activate :relative_assets

set :css_dir, 'stylesheets' 
set :js_dir, 'javascripts'
set :images_dir, 'images'

In my applications.css.sass I have this:

body
  background: image_url("background.png")

The background image is in images/background but Middleman doesn't find/load that image. It just puts this out:

body {
  background: url("../images/background.png");
}

Does anyone know what I'm doing wrong?

Upvotes: 4

Views: 3839

Answers (2)

Adam Lowe
Adam Lowe

Reputation: 1

body {
  background: url("/images/background.png");
}

Upvotes: 0

Karim Tarek
Karim Tarek

Reputation: 907

#Use relative URLs   
activate :relative_assets

I believe this is within the "build" configurations so it won't have any effect on your working file that you are viewing in middleman local server.

for me using this works "/images/hp/wmn.png"

I guess you just need to figure out the write path to your asset, as a temporary solution you can use an absolute link starting with your local server address //0.0.0.0:4567/ for mac or //localhost:4567/ for windows

Upvotes: 2

Related Questions