Jekyll `site.posts` 在将自定义域与 Github 页面合并后显示为空
Jekyll `site.posts` appearing empty after incorporating custom domain with Github page
我正在使用 Jekyll 构建一个简单的静态站点作为我的个人网站。我正在使用 GitHub 页面来托管它 (https://username.github.io)。最近我试图将我的自定义域与它合并并遇到问题。
例如,我有一个标题为posts.html
的页面,其内容是这样的:
---
layout: page
title: Posts
permalink: posts
---
Some Text
<ul>
{% for post in site.posts %}
<li> List item </li>
{% endfor %}
</ul>
之前一切都按预期出现。但是在合并自定义域后,没有列表项出现(即使我在本地 运行 时一切都很完美)。我想 site.posts
看起来是空的。有什么建议吗?
我有另一个类似下面的页面,它循环遍历 site.posts
以外的内容。即使在合并自定义域后它看起来也很完美。
---
layout: page
title: Books I Have Read
permalink: read-books
---
Some text
<ul>
{% for book in site.data.read-books %}
<li>
<a href={{book.goodreads}}> {{book.title}} </a>;
{{book.author}} [{{book.date}}]
{% if book.comment %}
<br/>
(Opinion: {{book.comment}})
{% endif %}
</li>
{% endfor %}
</ul>
我的帖子格式:YYYY-MM-DD-title.md
帖子目录名称:_posts
本地 Jekyll 版本为:3.7.0
_config.yml
内容:
Title: Md. Taufique Hussain
brieftitle: Taufique
baseUrl: ""
# Where things are
source: .
destination: ./_site
collections_dir: .
plugins_dir: _plugins
layouts_dir: _layouts
data_dir: _data
includes_dir: _includes
collections:
posts:
output: true
# Handling Reading
safe: false
include: [".htaccess"]
exclude: ["Gemfile", "Gemfile.lock", "node_modules", "vendor/bundle/", "vendor/cache/", "vendor/gems/", "vendor/ruby/"]
keep_files: [".git", ".svn"]
encoding: "utf-8"
markdown_ext: "markdown,mkdown,mkdn,mkd,md"
strict_front_matter: false
# Filtering Content
show_drafts: null
limit_posts: 0
future: false
unpublished: false
# Plugins
whitelist: []
plugins:
- jekyll-seo-tag
# Conversion
markdown: kramdown
highlighter: rouge
lsi: false
excerpt_separator: "\n\n"
incremental: false
# Serving
detach: false
port: 4000
host: 127.0.0.1
baseurl: "" # does not include hostname
show_dir_listing: false
# Outputting
permalink: date
paginate_path: /page:num
timezone: null
quiet: false
verbose: false
defaults: []
liquid:
error_mode: warn
# Markdown Processors
rdiscount:
extensions: []
redcarpet:
extensions: []
kramdown:
auto_ids: true
entity_output: as_char
toc_levels: 1..6
smart_quotes: lsquo,rsquo,ldquo,rdquo
input: GFM
hard_wrap: false
footnote_nr: 1
首先你想在 Github 页面配置中本地测试 Jekyll,你的 Gemfile 必须包含:
source "https://rubygems.org"
gem 'github-pages'
将加载 gh 页面上可用的所有插件,请参阅 complete list here。
这将允许您重现来自您的配置指令之一的 gh 页面错误:
collections_dir: .
如果您删除或评论此指令,一切都会恢复正常。
我正在使用 Jekyll 构建一个简单的静态站点作为我的个人网站。我正在使用 GitHub 页面来托管它 (https://username.github.io)。最近我试图将我的自定义域与它合并并遇到问题。
例如,我有一个标题为posts.html
的页面,其内容是这样的:
---
layout: page
title: Posts
permalink: posts
---
Some Text
<ul>
{% for post in site.posts %}
<li> List item </li>
{% endfor %}
</ul>
之前一切都按预期出现。但是在合并自定义域后,没有列表项出现(即使我在本地 运行 时一切都很完美)。我想 site.posts
看起来是空的。有什么建议吗?
我有另一个类似下面的页面,它循环遍历 site.posts
以外的内容。即使在合并自定义域后它看起来也很完美。
---
layout: page
title: Books I Have Read
permalink: read-books
---
Some text
<ul>
{% for book in site.data.read-books %}
<li>
<a href={{book.goodreads}}> {{book.title}} </a>;
{{book.author}} [{{book.date}}]
{% if book.comment %}
<br/>
(Opinion: {{book.comment}})
{% endif %}
</li>
{% endfor %}
</ul>
我的帖子格式:YYYY-MM-DD-title.md
帖子目录名称:_posts
本地 Jekyll 版本为:3.7.0
_config.yml
内容:
Title: Md. Taufique Hussain
brieftitle: Taufique
baseUrl: ""
# Where things are
source: .
destination: ./_site
collections_dir: .
plugins_dir: _plugins
layouts_dir: _layouts
data_dir: _data
includes_dir: _includes
collections:
posts:
output: true
# Handling Reading
safe: false
include: [".htaccess"]
exclude: ["Gemfile", "Gemfile.lock", "node_modules", "vendor/bundle/", "vendor/cache/", "vendor/gems/", "vendor/ruby/"]
keep_files: [".git", ".svn"]
encoding: "utf-8"
markdown_ext: "markdown,mkdown,mkdn,mkd,md"
strict_front_matter: false
# Filtering Content
show_drafts: null
limit_posts: 0
future: false
unpublished: false
# Plugins
whitelist: []
plugins:
- jekyll-seo-tag
# Conversion
markdown: kramdown
highlighter: rouge
lsi: false
excerpt_separator: "\n\n"
incremental: false
# Serving
detach: false
port: 4000
host: 127.0.0.1
baseurl: "" # does not include hostname
show_dir_listing: false
# Outputting
permalink: date
paginate_path: /page:num
timezone: null
quiet: false
verbose: false
defaults: []
liquid:
error_mode: warn
# Markdown Processors
rdiscount:
extensions: []
redcarpet:
extensions: []
kramdown:
auto_ids: true
entity_output: as_char
toc_levels: 1..6
smart_quotes: lsquo,rsquo,ldquo,rdquo
input: GFM
hard_wrap: false
footnote_nr: 1
首先你想在 Github 页面配置中本地测试 Jekyll,你的 Gemfile 必须包含:
source "https://rubygems.org"
gem 'github-pages'
将加载 gh 页面上可用的所有插件,请参阅 complete list here。
这将允许您重现来自您的配置指令之一的 gh 页面错误:
collections_dir: .
如果您删除或评论此指令,一切都会恢复正常。