html – Middleman路径不在子目录上工作

所以,这是我的第一个中间人项目,我正在努力解决中间人管理链接的问题.

实际上,我已经在github页面上进行了设置.我的所有资产都在工作,所以我做对了,但由于网站位于子目录中,导致每个页面的路径都失败了.

基本上root / directoryname / index.html有效但每个链接都返回一个目录,所以我应该有root / directoryname / page.html我得到root / page.html.

Here,have a link to see it live

这是我的config.rb的样子:

# Reload the browser automatically whenever files change
configure :development do
activate :livereload
end

# Methods defined in the helpers block are available in templates
# helpers do
#   def some_helper
#     "Helping"
#   end
# end

set :css_dir,'css'

set :js_dir,'js'

set :images_dir,'img'

# Build-specific configuration
configure :build do
  # For example,change the Compass output style for deployment
  activate :minify_css

  # Minify Javascript on build
  activate :minify_javascript

  # Enable cache buster
  activate :asset_hash

  # Use relative URLs
  activate :relative_assets

  activate :directory_indexes

  # Or use a different image path
  # set :http_prefix,"/Content/images/"
end

activate :deploy do |deploy|
  deploy.method = :git
  # Optional Settings
  # deploy.remote   = "custom-remote" # remote name or git url,default: origin
  # deploy.branch   = "custom-branch" # default: gh-pages
  # deploy.strategy = :submodule      # commit strategy: can be :force_push or :submodule,default: :force_push
end

data.works.each do |item|
  proxy "/references/#{item.clean}.html","/work.html",:locals => { :code => item },:ignore => true
end

helpers do
    # Sets the html class to 'active' when the link url is equal to the current page being viewed.
    # Use just like the link_to helper.
    # <%= magic_link_to 'Home','/index.html' %>
    def magic_link_to(link,url,opts={})
        current_url = current_resource.url
        if current_url == url_for(url) || current_url == url_for(url) + "/"
            opts[:class] = "active"
        end
        link_to(link,opts)
    end
end

这是我的主菜单的样子:

你们有什么感想 ?我错过了什么?

最佳答案
这是将Middleman项目部署到Github Pages的基本问题.

问题是Github Pages将网站部署到子文件夹,所以当你有一个绝对链接时,e. G. < a href =“/ services.html”>,它将始终指向错误的位置.

您需要将Middleman切换到相对链接模式.将其添加到config.rb:

set :relative_links,true

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Mip是什么意思以及作用有哪些
怎么测试Mip页面运行情况
MIP安装的具体步骤有哪些
HTML添加超链接、锚点的方法及作用详解(附视频)
MIP的规则有哪些
Mip轮播图组件中的重要属性讲解
Mip的内联框架组件是什么
怎么创建初始的MIP配置及模板文件
HTML实现多选框及无法提交多数据的原因分析(附视频)
HTML如何设置复选框、单选框以及默认选项?(图文+视频)
怎么使用MIP组件
Div垂直居中效果怎么实现
HTML如何实现视频在线播放
如何使用Mip代码校验工具
Mip中弹出层组件是什么
如何用HTML实现简单按钮样式
Mip中快速回顶组件怎么用
Div内容居中效果如何实现
Div水平居中效果怎么实现
Mip中列表组件怎么用