【问题标题】:Jekyll gh-pages disappearing site urlJekyll gh-pages 消失的站点 url
【发布时间】:2017-07-17 16:15:19
【问题描述】:

我使用 jekyll 和 githubpages 建立了一个博客,在我添加了一个自定义域名之前,一切都很顺利。添加自定义域名后,网站中嵌入到博客其他部分(首页除外)的任何链接都会损坏。

http://blog.com/about becomes -> http://about
http://blog.com/contact becomes -> http://contact

我可以手动输入任何地址,它工作正常,但如果我点击网站上的链接到帖子、关于页面或联系页面,我会得到损坏的 URL。如何阻止 url 的站点部分消失?链接到下面的博客及其存储库

【问题讨论】:

    标签: hyperlink jekyll liquid github-pages


    【解决方案1】:

    要生成正确的 URL,您需要添加 site.url 变量。

    您可以在index.html 中手动生成网址:

      {{site.url}}/{{ site.baseurl }}{{ post.url }}
    

    或使用absolute_url 自动添加它们(它预先添加site.urlsite.baseurl):

     <a href="{{ post.url|absolute_url }}">{{ post.title }}</a>
    

    【讨论】:

      猜你喜欢
      • 2018-02-02
      • 1970-01-01
      • 2017-05-20
      • 1970-01-01
      • 2015-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多