diff --git a/middleman-core/lib/middleman-core/application.rb b/middleman-core/lib/middleman-core/application.rb index 7a12cbfa..dcf9bf1e 100644 --- a/middleman-core/lib/middleman-core/application.rb +++ b/middleman-core/lib/middleman-core/application.rb @@ -93,7 +93,11 @@ module Middleman # @return [String] set :index_file, "index.html" - # Whether to include a trailing slash on links to directory indexes + # Whether to strip the index file name off links to directory indexes + # @return [Boolean] + set :strip_index_file, true + + # Whether to include a trailing slash when stripping the index file # @return [Boolean] set :trailing_slash, true diff --git a/middleman-core/lib/middleman-core/sitemap/resource.rb b/middleman-core/lib/middleman-core/sitemap/resource.rb index 481212f6..da8e8f84 100644 --- a/middleman-core/lib/middleman-core/sitemap/resource.rb +++ b/middleman-core/lib/middleman-core/sitemap/resource.rb @@ -141,8 +141,12 @@ module Middleman # just foo. Best for linking. # @return [String] def url - File.join(app.respond_to?(:http_prefix) ? app.http_prefix : '/', - destination_path.sub(/\/#{Regexp.escape(app.index_file)}$/, app.trailing_slash ? '/' : '')) + url_path = destination_path + if app.strip_index_file + url_path = url_path.sub(/\/#{Regexp.escape(app.index_file)}$/, + app.trailing_slash ? '/' : '') + end + File.join(app.respond_to?(:http_prefix) ? app.http_prefix : '/', url_path) end end end