首页 文章

jekyll博客固定链接中断并收益“未找到404”

提问于
浏览
0

我已经开了一个小网站,上面有几页和几篇博文 . 它托管在我组织的服务器上,我将_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/博客-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%}

我原以为{}会自动为帖子插入正确的网址,但显然这种情况并没有发生 . :(

我搞砸了哪里?

(Jekyll版本3.1.2)

注意:http://之后的空格是故意的,因为StackExchange认为我正在发布链接,而这显然是不允许的 . 在我的实际markdown和html中,它们是正确的URL .

1 回答

  • 0

    链接到集合项(帖子是集合项)或页面:

    例如: <a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a>

    <a href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>

    资源链接(图像,脚本,CSS,......)也是如此 .

    例如: <link rel="stylesheet" href="{{ "/css/main.css" | prepend: site.baseurl }}">

    <script src="{{ site.baseurl }}/js/script.js"></script>

相关问题