【问题标题】:How to set up permalinks with variables in jekyll?如何在 jekyll 中使用变量设置永久链接?
【发布时间】:2019-07-27 17:07:02
【问题描述】:

我正在尝试设置 jekyll,以便它会自动为新帖子创建永久链接,但它不起作用。

我所做的是在 _config.yml 中设置一个变量,如下所示:

permalink: /:title/

然后,在主页上的帖子预览循环中,我创建了一个这样的链接:

<a href="{{ post.permalink }}">Read More</a>

期望输出是这样的。

<a href="/I-am-the-title-of-this-post">Read More</a>

相反,我得到了这个:

<a href="/:title/">Read More</a>

如果我单击它会给出 404 Not Found 错误。

我做错了什么?

更多信息here是github repo。

谢谢!

马特奥

【问题讨论】:

  • 使用{{ site.baseurl }}{{ post.url }}
  • 谢谢!这很容易。

标签: jekyll liquid permalinks


【解决方案1】:

正如@David Jaquel 建议的那样,我通过使用解决了

{{ site.baseurl }}{{ post.url }}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-15
    • 2011-08-19
    • 1970-01-01
    相关资源
    最近更新 更多