【问题标题】:How to set a collection with jekyll on github page?如何在 github 页面上使用 jekyll 设置集合?
【发布时间】:2021-06-24 12:25:24
【问题描述】:

我按照Collections | Jekyll • Simple, blog-aware, static sites的官方指南将收藏添加到我的博客wow-yes.github.io。

我已将staff_members 添加到_config.yml。所有来源都存储在GitHub - wow-yes/blog: my personal blog.

collections:
    my_collection:
        output: true
    staff_members:
        output: true
        people: true

我还将jane.md 添加到文件夹_staff_members 中。

当我在本地电脑上测试时,一切正常。 http://127.0.0.1:4000/staff_members/jane.html 效果很好。

但是当我在 github 页面上打开 https://wow-yes.github.io/staff_members/jane.html 时,我得到一个 404 页面 Site not found · GitHub Pages

看来 Github 没有编译 jane.md。

谢谢。

【问题讨论】:

    标签: github jekyll github-pages


    【解决方案1】:

    我自己解决了这个问题。

    此链接https://wow-yes.github.io/staff_members/jane.html 错误。右边是https://wow-yes.github.io/blog/staff_members/jane.html。 Github 已编译 jane.md 但我没有得到正确的链接。

    github-pages 地址上缺少/blog/。好吧,所以我将{{site.baseurl}} 添加到_layout/collections.html 中,为我的收藏生成正确的网址。它在我的本地服务器和 github 页面上运行良好。

    官方指南Collections | Jekyll • Simple, blog-aware, static sites 就在本地服务器上。但是当你将此代码应用到github页面时,请在{{ staff_member.url }}之前添加{{site.baseurl}}。例如:

    {% for staff_member in site.staff_members %}
      <h2>
        <a href="{{ site.baseurl }}{{ staff_member.url }}">
          {{ staff_member.name }} - {{ staff_member.position }}
        </a>
      </h2>
      <p>{{ staff_member.content | markdownify }}</p>
    {% endfor %}
    

    【讨论】:

      猜你喜欢
      • 2015-01-09
      • 1970-01-01
      • 2013-06-26
      • 2019-11-03
      • 2018-04-01
      • 2018-06-23
      • 1970-01-01
      • 2020-09-10
      • 2017-11-12
      相关资源
      最近更新 更多