url 的 Jekyll 帖子导航在推送到 github 时不起作用

url of navigations of jekyll posts do not work when pushed to github

我想在 github 页上的博文中添加导航功能。

我在 post.html 中添加了以下代码:

<div class="PageNavigation">
  {% if page.previous.url %}
    <a class="prev" href="{{page.previous.url}}">&laquo;
        {{page.previous.title}}</a>
  {% endif %}
  ...
</div>

当我将帖子推送到 github 时,link 将无法工作,因为代码位于存储库 url 下。 作为解决方法,我手动将回购名称添加到 link。它变成:

 <a class="prev" href="/myRepoName{{page.previous.url}}">&laquo;
        {{page.previous.title}}</a>

现在的问题是导航在本地不起作用。有没有简单的解决方案来避免这种混乱?

_config.yml中:

baseurl: /myRepoName

Link 看起来像:

<a href="{{ site.baseurl }}{{ page.previous.url }}" class="prev">
  {{page.previous.title}}
</a>