Jekyll 重定向到 404 并且不呈现 post.md
Jekyll redirects to a 404 and does not render post.md
我希望我的 index.md 在
上看到
重定向到我用 markdown 编写的页面
我尝试实施 post_url 变量,如记录
为了成功重定向到用 markdown 编写的页面但没有成功,因为它指向 404 at
[Name of Link]({% post_url 2010-07-21-name-of-post %})
http://www.jekyllrb.com/docs/liquid/tags/#linking-to-posts
起初我以为这是 for 循环的错误,所以我手动添加了 link,具体在文档中详细说明了用 markdown 编写的页面。
index.md
# Index of all my content
[Library Carpentry Workshop July 2020]({% post_url 2020-07-27-library-carpentry-workshop-american-university-notes %})
<ul>
{% for post in site.posts %}
<li>
<a href="{{ post.url }}">{{ post.title }}</a>
</li>
{% endfor %}
</ul>
_config.yml
theme: jekyll-theme-slate
url: https://jtm-lis.github.io
baseurl: /Julien_Tremblay_McLellan #NO TRAILING SLASH
title: Julien Tremblay McLellan's Website
author: Julien Tremblay McLellan
email: jtremc@gmail.com
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.
# social links
twitter_username: jtm-lis # DO NOT include the @ character, or else the build will fail!
github_username: jtm-lis # DO NOT include the @ character, or else the build will fail!
show_excerpts: true # set to false to remove excerpts on the homepage
我做错了什么?
这里的问题是 link 没有使用 site.baseurl
,
所以而不是 linking 到
https://jtm-lis.github.io/Julien_Tremblay_McLellan/2020/07/27/library-carpentry-workshop-american-university-notes.html
您正在 link
https://jtm-lis.github.io/2020/07/27/library-carpentry-workshop-american-university-notes.html
不存在。
修复很简单,您只需将 site.baseurl
添加到 link 中,如
[Name of Link]({% post_url 2010-07-21-name-of-post | prepend: site.baseurl %})
执行此操作时,您可能会在 localhost
环境中遇到其他问题,因为您的 site.baseurl
文件夹很可能不存在。因此它可以在您的实时站点上运行,但在您的本地环境中已损坏 links。
要在 localhost
上正常工作,只需在服务时覆盖 baseurl
属性:
jekyll serve --baseurl ""
或者如果您使用捆绑器
bundler exec jekyll serve --baseurl ""
我希望我的 index.md 在
上看到重定向到我用 markdown 编写的页面
我尝试实施 post_url 变量,如记录 为了成功重定向到用 markdown 编写的页面但没有成功,因为它指向 404 at
[Name of Link]({% post_url 2010-07-21-name-of-post %})
http://www.jekyllrb.com/docs/liquid/tags/#linking-to-posts
起初我以为这是 for 循环的错误,所以我手动添加了 link,具体在文档中详细说明了用 markdown 编写的页面。
index.md
# Index of all my content
[Library Carpentry Workshop July 2020]({% post_url 2020-07-27-library-carpentry-workshop-american-university-notes %})
<ul>
{% for post in site.posts %}
<li>
<a href="{{ post.url }}">{{ post.title }}</a>
</li>
{% endfor %}
</ul>
_config.yml
theme: jekyll-theme-slate
url: https://jtm-lis.github.io
baseurl: /Julien_Tremblay_McLellan #NO TRAILING SLASH
title: Julien Tremblay McLellan's Website
author: Julien Tremblay McLellan
email: jtremc@gmail.com
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.
# social links
twitter_username: jtm-lis # DO NOT include the @ character, or else the build will fail!
github_username: jtm-lis # DO NOT include the @ character, or else the build will fail!
show_excerpts: true # set to false to remove excerpts on the homepage
我做错了什么?
这里的问题是 link 没有使用 site.baseurl
,
所以而不是 linking 到
https://jtm-lis.github.io/Julien_Tremblay_McLellan/2020/07/27/library-carpentry-workshop-american-university-notes.html
您正在 link
https://jtm-lis.github.io/2020/07/27/library-carpentry-workshop-american-university-notes.html
不存在。
修复很简单,您只需将 site.baseurl
添加到 link 中,如
[Name of Link]({% post_url 2010-07-21-name-of-post | prepend: site.baseurl %})
执行此操作时,您可能会在 localhost
环境中遇到其他问题,因为您的 site.baseurl
文件夹很可能不存在。因此它可以在您的实时站点上运行,但在您的本地环境中已损坏 links。
要在 localhost
上正常工作,只需在服务时覆盖 baseurl
属性:
jekyll serve --baseurl ""
或者如果您使用捆绑器
bundler exec jekyll serve --baseurl ""