Middleman build puts a slash in front of everything

I’m using Middleman for a pretty simple portfolio website. And it’s pretty great, been using some gems like bourbon and neat for gridbased design and easy CSS3 acces!

A small (but irritating) problem I do have with Middelman is that when I build my project all my paths get a “/” in front of it.

Meaning <img src='images/profile-me.png'> becomes <img src='/images/profile-me.png'> and then I have to change it in the code. Middleman does this to my stylesheets and scripts too.

Have you read about :relative_links on the http://middlemanapp.com/basics/helpers/ docs?

1 Like

yup, just add set :relative_links, true to your config.rb.

I’m having a similar issue, but have relative assets set to true on build. It’s only affecting paths for background images in my CSS … as an example, the following path works while the server is running, but on build, and then push to Github pages— the path fails.

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

On build my config includes:

  activate :relative_assets
  set :relative_links, true

What am I missing, or not understanding?

Thanks!

Solved it on my own— but for reference:

While /images/pattern.png works with the server running, on build the path requires moving up a directory, out of stylesheets, and then into images. Using ../images.pattern.png is what I needed. I just assumed on build it would get included.

1 Like