开发工具 Jekyll 相对路径

song940 · January 15, 2014 · Last by song940 replied at January 15, 2014 · 4033 hits

我如何让 Jekyll 生成的 _site 同时运行在 Github Page (根目录) 和 https://lsong.org/~lsong(子目录) ?

求解 .

{{ site.baseurl }}/path/to/assets

baseurl 设置在 _config.yml,不同站点用不同的设置。

#1 楼 @Rei 想过这个 ... 有没有更好地办法 ....

#3 楼 @Rei

class Jekyll::Page

  def relative
    "../" * (url.split("/").length-2)
  end

  def to_liquid(attrs = ATTRIBUTES_FOR_LIQUID)
    super(attrs + %w[
          relative
    ])

  end
end

class Jekyll::Post

  def relative
    "../" * (url.split("/").length-2)
  end

  def to_liquid(attrs = ATTRIBUTES_FOR_LIQUID)
    super(attrs + %w[
          relative
    ])

  end
end

有人这么干 .... 但是 ... 仍有问题 .


他的思路是 , 保留 2 级的路径 . 其他全用相对 .

不知道我折腾的方向对不对 , 容我再想想 ....

You need to Sign in before reply, if you don't have an account, please Sign up first.