我已经开始使用 GutHub-Pages。我正在使用Jekyll和我的gh-pages
存储库具有以下结构:
gh-pages (repo)
+-site
| +-_posts
| +-2016-02-15-post1.md
| +-_config.yml
| +-index.html
+-notes.md
我的index.html
是这样的:
---
layout: default
---
<div class="home">
<h1 class="page-heading">Posts</h1>
<ul class="post-list">
{% for post in site.posts %}
<li>
<span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span>
<h2><a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a></h2>
</li>
{% endfor %}
</ul>
<p class="rss-subscribe">subscribe <a href="{{ "/feed.xml" | prepend: site.baseurl }}">via RSS</a></p>
</div>
错误的路径
这样我就可以访问我的页面网址:http://<username>.github.io/<project-name>
并降落在index.html
正好。但是当我点击链接帖子时,我得到这个地址:
http://<username>.github.io/jekyll/update/2016/02/15/post1.html
这会导致 404,因为正确的路径是:
http://<username>.github.io/jekyll/<project-name>/update/2016/02/15/post1.html
项目名文件夹不算在内!
最佳答案
在_config.yml
中,设置
baseurl: /project-name
关于git - Jekyll 的 GitHub 页面中的帖子链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36143738/