【发布时间】:2016-09-10 07:02:27
【问题描述】:
我创建了一个包含几页和几篇博客文章的小型网站。它托管在我组织的服务器上,我将 _site/ 目录的所有内容通过 ftp 传输到网站的子目录中。因此 Jekyll 站点位于 http://myusername.foobar.foo/thiswebsite/ 。
在我的 _config.yml 中
baseurl: "/thiswebsite"
url: "http:// myusername.foobar.foo"
现在所有页面都能正确显示。但博客文章不会。
在每篇博文的 YAML 前言中:
permalink: /:title.html
然后我最终在 index.html 页面上生成了指向 http://myusername.foobar.bar/blog-title.html 的博客文章的链接,但实际的博客文章位于 http://myusername.foobar.bar /thiswebsite/blog-title.html。因此,如果人们点击 index.html 上的链接,他们将看到 404。
在 index.html 上我有:
{% for post in site.posts %}
<h2><a href="{{ post.url }}">{{ post.title }}</a></h2>
<blockquote>
{{ post.excerpt }}
</blockquote>
{% endfor %}
我原以为{{ post.url }} 会自动为帖子插入正确的 URL,但显然这并没有发生。 :(
我在哪里搞砸了?
(Jekyll 版本 3.1.2)
注意:http:// 后面的空格是故意的,因为 StackExchange 认为我在发布链接,这显然是不允许的。在我实际的 markdown 和 html 中,它们是正确的 URL。
【问题讨论】:
-
在配置中设置 baseurl 时需要
{{site.baseurl}}{{post.url}}
标签: jekyll