I’m trying to set up a Middleman blog and build it to a staging server in a subdirectory of the root.
The issue I’m running into is that while the paths to articles build as relative links href=“articles/tuples-in-c/”
without a starting forward slash, tag_path is getting written with a starting forward slash, causing broken links.
The link gets written like href="/blog/tags/development"
, so that instead of root/subdirectory/tag/
, I’m getting a link to root/tag/
when I build. This only happens when I have directory_indexes turned on, which is a requirement of the project.
I’ve tried changing the blog.taglink, I’ve tried moving set :relative_links, true
around in the config, I’ve tried all sorts of things, but nothing works. Same problem with my custom collection of authors. How do I create relative links in the blog with directory_indexes turned on?
Thanks!
config.rb
activate :authors
activate :blog do |blog|
blog.permalink = “blog/articles/{title}.html”
blog.sources = “blog/articles/{title}.html”
blog.taglink = “blog/tags/{tag}.html”
blog.new_article_template = ‘blog/template.html.erb’
blog.tag_template = “tag.html”
blog.custom_collections = {
author: {
link: ‘{author}.html’,
template: ‘blog/author.html’
}
}
end
activate :directory_indexes
activate :relative_assets
set :relative_links, true
index.html.erb
<% page_articles.each_with_index do |article, i| %>
<% link_to article do %>
<%= image_tag article.data.image.first %>
<%= article.title.first %>
<% end %>
<%= article.summary %>
<%= link_to article.data.author, author_path(article.data.author) %>
<%= article.date.strftime(’%b %e’) %>
<% article.tags.each do |tag| %>
<%= link_to “#{tag}”, tag_path(tag), :class=>“tag-badge” %>
<% end %>
<% end %>