gpt4 book ai didi

GitHub 上的 Jekyll 页面 : permalinks don't include baseurl

转载 作者:行者123 更新时间:2023-12-02 20:31:47 24 4
gpt4 key购买 nike

我正在处理a guide用于在 GitHub Pages 上设置 Jekyll。我的 GitHub 存储库发布到 ~.github.io/hello-pages ,所以我很自然地要插入{{ site.baseurl }}插入 anchor 标记等。效果很好。

不起作用的是永久链接:我必须手动拼出 permalink: /hello-pages/blog/:year/:month/:day/:title.html_config.yml使任何永久链接正常工作;否则它们会链接到例如~.github.io/blog/x/y/z而不是~.github.io/hello-pages/blog/x/y/z正如我所期望的。

手动指定baseurl: /hello-pages没有效果(我想 GitHub 的 Jekyll 配置已经做到了这一点)。

在任何地方手动输入“/hello-pages”似乎是一种我想避免的严格设计。 An older SO answer说永久链接应该“正常工作”。给出了什么?


编辑

我正在构建这样的损坏的 URL:

<a href="{{ post.url }}">

最佳答案

我刚刚发现我做错了什么。我需要做以下事情之一。以下是有关此内容的文档:https://jekyllrb.com/docs/templates/#filters

<a href="{{ post.url | relative_url }}">

这会将 URL 转换为相对 URL,同时考虑基本 URL。

<a href="{{ post.url | absolute_url }}">

与上面相同,但使用绝对 URL。

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

将基本 URL 添加到永久链接前面。

关于GitHub 上的 Jekyll 页面 : permalinks don't include baseurl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48446166/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com