LoginSignup
17
16

More than 5 years have passed since last update.

Middlemanのlink_toを相対パスにする。そしてindex.htmlを省略させない

Last updated at Posted at 2014-11-11

ローカルで見られるサイトをMiddlemanで生成したかったんですが、ちょっとはまったのでメモ

ルート相対パスになっちゃう

config.rb
set :relative_links, true

と書けばmiddleman buildしたときにドキュメント相対パスになるはずなんですが、ならない・・・

原因

foo.html.erb
<!-- これではだめ -->
<%= link_to "Foo", "/bar/" %>

<!-- ファイル名まで必要 -->
<%= link_to "Foo", "/bar/index.html" %>

index.htmlが省略されちゃう

ローカルだとディレクトリインデックスが効かないので、これでは困ります。。。

対策

config.rb
set :strip_index_file, false

これを書けばOKでした。

17
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
16