出于某种原因,我的Middleman博客没有从我的相关图片链接中为我的某个目录生成正确的网址,而且我不能为我的生活找出它出错的地方。
所以我的构建目录就像这样
build
-software
--article1
---index.html
--article2
--article3
-design
-reviews
-misc
-images
-stylesheets
-tags
相对路径几乎适用于所有事情,例如我链接到软件文章1中的图像。 Markdown代码为![test](test.jpg)
,html为"../../images/test.jpg"
然而,当我在设计中发布博客文章时,尽管使用相同的降价,该文章的关联html仍为"/images/test.jpg"
。我不知道为什么它会为设计中的所有帖子做这件事。
经过进一步测试,显然如果任何特定文件夹中只有一个帖子,它将无法生成正确的代码,所以请确保我仍然理智,我复制帖子只更改日期和第二个产生的html产生正确相对路径,它也更新了原始,并给它正确解析的相对路径。但是当我删除副本时,它会更新剩余的并将其更改回"images/test.jpg"
我的配置文件,如果需要。
###
# Blog settings
###
Time.zone = "EST"
activate :syntax
set :fonts_dir, "fonts-folder"
set :markdown_engine, :redcarpet
set :markdown, :fenced_code_blocks => true,
:smartypants => true,
:tables => true,
:highlight => true,
:with_toc_data => true
activate :blog do |blog|
blog.custom_collections = {
category: {
link: '{category}.html',
template: 'category.html'
}
}
# This will add a prefix to all links, template references and source paths
# blog.prefix = "{category}"
blog.name = "blog"
blog.permalink = "{category}/{title}.html"
blog.sources = "{category}/{title}.html"
#blog.taglink = "{tag}.html"
# blog.layout = "layout"
blog.summary_separator = /(READMORE)/
blog.summary_length = 185
# blog.year_link = "{year}.html"
# blog.month_link = "{year}/{month}.html"
# blog.day_link = "{year}/{month}/{day}.html"
# blog.default_extension = ".markdown"
blog.tag_template = "tag.html"
#blog.calendar_template = "calendar.html"
# Enable pagination
# blog.paginate = true
# blog.per_page = 10
# blog.page_link = "page/{num}"
end
activate :deploy do |deploy|
deploy.method = :git
deploy.branch = 'master'
deploy.build_before = true
deploy.commit_message = "New blog entry go!"
end
activate :minify_html do |html|
html.remove_multi_spaces = true
html.remove_comments = true
end
activate :directory_indexes
page "/feed.xml", layout: false
###
# Compass
###
# Change Compass configuration
# compass_config do |config|
# config.output_style = :compact
# end
###
# Page options, layouts, aliases and proxies
###
# Per-page layout changes:
#
# With no layout
# page "/path/to/file.html", layout: false
#
# With alternative layout
# page "/path/to/file.html", layout: :otherlayout
#
# A path which all have the same layout
# with_layout :admin do
# page "/admin/*"
# end
# Proxy pages (http://middlemanapp.com/basics/dynamic-pages/)
# proxy "/this-page-has-no-template.html", "/template-file.html", locals: {
# which_fake_page: "Rendering a fake page with a local variable" }
###
# Helpers
###
# Automatic image dimensions on image_tag helper
#activate :automatic_image_sizes
set :css_dir, 'stylesheets'
set :js_dir, 'javascripts'
set :images_dir, 'images'
activate :livereload
# Build-specific configuration
configure :build do
activate :minify_css
activate :relative_assets
# Or use a different image path
# set :http_prefix, "/Content/images/"
end
答案 0 :(得分:0)
我不确定您是否已经尝试过,或者它是否会修复它,但您可以尝试添加
set :relative_links, true
到您的配置文件?