【发布时间】:2014-12-12 07:38:02
【问题描述】:
Jekyll 中的链接有点问题。
例如,我在文件夹中有一个帖子:
file:///C:/Users/My%20Name/Documents/jekyll_site/2014-10-25-Workshop.html
当我使用jekyll build 时,帖子被插入到这个文件夹中:
file:///C:/Users/My%20Name/Documents/jekyll_site/_site/2014/10/25/Workshop.html
在帖子模板中,我使用这个简单的代码转到下一页或上一页:
{% if page.previous.url %}
<p class="previousEntry blueButton"> <a href="{{page.previous.url}}"><< Go to older entry</a></p>
{% else %}
<p class="previousEntry blueButton"><< Go to older entry</p>
{% endif %}
当我运行jekyll serve 时,http://localhost:4000 看起来一切正常,
但是,当我查看jekyll build 之后生成的代码时,它看起来像这样:
<p class="previousEntry blueButton"> <a href="/2013/04/12/FirstVisit.html"><< Go to older entry</a></p>
<p class="nextEntry blueButton"><a href="/2014/07/09/OfficialMeeting.html">Go to newer entry >></a></p>
<p class="backToNews blueButton"><a href="news.html">Go back to main news page</a></p>
而且,例如,当我点击“转到旧条目”时,我被定向到 file:///C:/2013/04/12/FirstVisit.html(这会导致“找不到此页面”页面)而不是 file:///C:/Users/My%20Name/Documents/jekyll_site/_site/2013/04/12/FirstVisit.html(即页面的当前位置)
当我尝试将其上传到网络服务器时,这会导致问题吗?如果是这样,我该如何制作,以便在我将其上传到网络服务器后,此相对链接会将用户定向到我想要的位置?
【问题讨论】:
-
这里有类似问题的答案:stackoverflow.com/a/14254928/2491604