为什么我全新的 Jekyll 博客在添加支持的 Hacker 主题后是空白的?

问题描述 投票:0回答:1

我正在尝试开始使用 Jekyll 博客。我按照 这些说明 使用默认的

minima
主题设置博客。这实际上没有任何问题,但我想更改为Hacker主题。为此,它只要求我进行以下更改
_config.yml

remote_theme: pages-themes/[email protected]
plugins:
- jekyll-remote-theme # add this line to the plugins list if you already have one

进行这些更改后,我访问了 URL https://galenseilis.github.io/,我发现没有任何内容再呈现。

可以在 https://github.com/galenseilis/galenseilis.github.io 观察当前状态,但除了我对 Gemfile 和

_config.yml
进行更改之外,一切都应该是默认值。但由于我在排除故障时可能会更改存储库的内容,因此这里是这些文件的快照:

宝石文件

source "https://rubygems.org"
# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
#     bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
# gem "jekyll", "~> 4.3.2"
# This is the default theme for new Jekyll sites. You may change this to anything you like.
# gem "minima", "~> 2.5"
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
gem "github-pages",  group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
  gem "jekyll-feed", "~> 0.12"
end

# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
# and associated library.
platforms :mingw, :x64_mingw, :mswin, :jruby do
  gem "tzinfo", ">= 1", "< 3"
  gem "tzinfo-data"
end

# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]

# Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem
# do not have a Java counterpart.
gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby]

_config.yml

title: Your awesome title
email: [email protected]
description: >- # this means to ignore newlines until "baseurl:"
  Write an awesome description for your new site here. You can edit this
  line in _config.yml. It will appear in your document head meta (for
  Google search results) and in your feed.xml site description.
baseurl: "" # the subpath of your site, e.g. /blog
url: "" # the base hostname & protocol for your site, e.g. http://example.com
twitter_username: jekyllrb
github_username:  jekyll

# Build settings
# theme: minima
# theme: jekyll-theme-hacker
remote_theme: pages-themes/[email protected]
plugins:
  - jekyll-feed
  - jekyll-remote-theme

使用

minima
主题将 Hacker 主题的建议更改恢复到原始状态会返回页面的呈现。那么也许我所做的改变是不够的,甚至是不正确的?

jekyll jekyll-theme jekyll-bootstrap
1个回答
0
投票

我刚刚将我的 Minima 转换为 Hacker 主题,并遇到了同样的问题。

在阅读了 Hacker 主题的存储库并从另一位开发人员那里得到以下提示后,我终于让它工作了:

Hacker 主题必须有包含以下文件的 _layouts 目录:

_layouts/home.html
_layouts/page.html
_layouts/post.html

page.html 和 post.html 的内容应该是相同的,至少现在是这样:

---
layout: default
---
    
{{ content }}

home.html 页面的内容应如下所示,即您必须迭代 _posts 目录下的每个文件:

---
layout: default
---

{{ content }}

{% if site.posts.size > 0 %}
<h2>Posts</h2>
<ul>
    {% for post in site.posts %}
    <li>
      <a href="{{ post.url | relative_url }}">{{ post.title }}</a>
    </li>  
    {% endfor %}
</ul>
{% endif %}

relative_url Liquid 过滤器似乎可以实现使 _posts 目录下的文件可用的技巧。

尽管如此,我很难解释这个解决方案,因为我自己是 Jekyll 的新手!

这是我的网站供参考:https://rio197.github.io/skills-github-pages/

© www.soinside.com 2019 - 2024. All rights reserved.