最近,我决定在Github Pages上启动我的博客。我分叉Jekyll现在并将代码拉入我的本地环境。Jekyll不读书site.posts
现在我正在运行jekyll serve
,但它不读取_posts文件夹中的帖子!
看来site.posts
变量index.html
无法读取。如果我输出变量或检查它:{{ site.posts | inspect }}
然后它是空的。
的职位名称中的正确格式YYYY-MM-DD-TITLE.md 如果我跑jekyll serve
的_posts
文件夹内,然后我会得到一个IndexOf
页面没有任何问题列出的所有文章。
的_config.yml
内容:
# Name of your site (displayed in the header)
name: My name
# Short bio or description (displayed in the header)
description: Blog on various topics
# URL of your avatar or profile pic (you could use your GitHub profile pic)
# avatar: https://raw.githubusercontent.com/barryclark/jekyll-now/master/images/jekyll-logo.png
# Includes an icon in the footer for each username you enter
footer-links:
github: motleis/blog
baseurl: ""
permalink: /:title/
# The release of Jekyll Now that you're using
version: v3.4.0
# Jekyll 3 now only supports Kramdown for Markdown
kramdown:
# Use GitHub flavored markdown, including triple backtick fenced code blocks
input: GFM
# Jekyll 3 and GitHub Pages now only support rouge for syntax highlighting
syntax_highlighter: rouge
syntax_highlighter_opts:
# Use existing pygments syntax highlighting css
css_class: 'highlight'
# Set the Sass partials directory, as we're using @imports
sass:
style: :expanded # You might prefer to minify using :compressed
# Use the following plug-ins
gems:
- jekyll-sitemap # Create a sitemap using the official Jekyll sitemap gem
- jekyll-feed # Create an Atom feed using the official Jekyll feed gem
# Exclude these files from your production _site
exclude:
- Gemfile
- Gemfile.lock
- LICENSE
- README.md
- CNAME
在_posts:我只有简单的示例文件: 2014-3-3-Hello-World.md
---
layout: post
title: You're up and running!
---
Just a single line that should be displayed!
这里而来的内容index.html
,帖子应该列出:
site.posts : {{ site.posts }}
My posts:
<ul>
{% for post in site.posts %}
<li>
<a href="{{ post.url }}">{{ post.title }}</a>
{{ post.excerpt }}
</li>
{% endfor %}
</ul>
结果如下:
site.posts :
My Posts:
正如你所看到的site.posts是空的!
你有什么建议来调试这个问题?
我正在jeykll-3.4.0
发布您位于'_posts'文件夹中的帖子及其文件名。还有'_config.yml'。 – marcanuy
感谢@marcanuy为您的评论和编辑我的问题中的标记。我只是编辑帖子,希望它更清楚 – mtleis
似乎没问题,它应该在根文件夹(即包含'_config.yml'的文件夹)上运行'jekyll serve' – marcanuy