Search code examples
middlemanmiddleman-4

How to get Middleman to get relative link for root url?


How do I get my root url to work with relative links? This tag does not seem to want to point to the right place.

<%= link_to 'Home', '/' %>

I can reproduce locally like this:

gem install middleman
middleman new site
cd site

echo "<%= link_to 'Home', '/' %>" > source/index.html.erb
echo "set :relative_links, true" >> config.rb
middleman build

# start webserver from the middleman root directory, not the build directory.
# This simulates a local url where the root url is not the `/`.

python -m SimpleHTTPServer &
open http://localhost:8000/build

You'll see that the "Home" link goes back to / instead of /build which is the relative home of the site.


Solution

  • I was able to to <%= link_to '/index.html', 'Home' %> to solve this.