首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >中间人和相关图像

中间人和相关图像
EN

Stack Overflow用户
提问于 2015-10-31 12:10:26
回答 1查看 921关注 0票数 0

由于某些原因,我的中间人博客无法从我的某个目录的相对图像链接中生成正确的url,而且我也找不出哪里出了问题。

所以我的build目录是这样的

代码语言:javascript
复制
build
-software
 --article1
  ---index.html
 --article2
 --article3
-design
-reviews
-misc
-images
-stylesheets
-tags

相对路径适用于几乎所有的东西,例如我在软件的article1中链接到一个图像。标记代码是![test](test.jpg),并且html读取"../../images/test.jpg"

然而,当我在design中写了一篇博客文章时,尽管使用了相同的标记,但那篇文章的相关html显示为"/images/test.jpg"。我不知道为什么它在设计中的所有帖子都是这样做的。

在进一步的测试中,如果在任何特定的文件夹中只有一篇文章,显然它不会产生正确的代码,所以请确保我仍然是正常的,我复制了这篇文章,只更改了日期,第二个结果html产生了正确的相对路径,它还更新了原始的,并给出了正确解析的相对路径。但当我删除副本时,它更新了其余的副本,并将其改回"images/test.jpg"

我的配置文件(如果需要)。

代码语言:javascript
复制
###
# 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
EN

回答 1

Stack Overflow用户

发布于 2015-11-14 11:36:00

我不确定您是否尝试过此方法,或者它是否可以修复它,但您是否可以尝试添加

set :relative_links, true

添加到您的配置文件?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33447963

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档