git - Jekyll 的 GitHub 页面中的帖子链接错误

标签 git github jekyll github-pages

我已经开始使用 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/

相关文章:

git - 有效的全局 .gitignore 步骤不会在 Mac OS 上生效

git - 从 GitHub 推送到 Web 服务器

ruby-on-rails - 使用 Jekyll 未在主页上呈现的帖子

jekyll - 如何为 octopress 博客安装 jekyll 插件?

git - 如何撤消成功的 "git cherry-pick"?

windows - 无法创建目录 '/home/username/.ssh'

github - 如何访问github中的管理按钮?

jekyll - 在 Jekyll 中,是否可以隐藏生产页面

git - 如何使用 Mercurial 为文件执行 "replace with the latest from head"?

git - 如何用我已经是最新的 fork 来表明我是 "merged"?