内部链接到文章不存在,Jekyll。

4

我运行了htmlproofer并得到了以下错误信息。

内部链接到 /posts/title,但该页面不存在

我应该如何修复Jekyll中的liquid标签,以便在构建时正确输出HTML代码?

我想这与 index.html 中的这行代码有关:

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

当我在这一行加入{{ post }}

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

文章至少会显示在index.html上,即使它使网站看起来不完整。当删除{{ post }}时,主页看起来正常,但是点击文章链接时会导致404错误...


仓库网址是多少? - David Jacquel
https://gitlab.com/mrjules/chalked5 - WinterJules
1个回答

3

HTMLProofer应该检查位于_site目录中的生成站点。这个文件夹包含了经过Jekyll处理的网站的生成文件,这样htmlproofer就可以正确地检查失败的链接。

例如:

htmlproofer --check-html \
        --internal-domains localhost:4000 \
        --assume-extension \
        --disable-external \
        _site

尝试使用 <a href="{{ post.url | absolute_url }}">{{ post.title </a>}} 并在 _config.yml 中设置属性:baseurl = "" - 或者 <a href="{{ post.url | prepend: site.baseurl }}">{{ post.title </a>}} - marcanuy
生成的URL是指向404页面的吗? - marcanuy
示例网址.com/项目名称/年份/月份/标题 或 https://mrjules.gitlab.io/chalked5/2016/10/configuring-chalk。我无法从“index.html”打开博客文章。 - WinterJules
刚刚下载了你的网站,对我来说可以正常运行,但是CI出现了问题吗?看起来永久链接存在一些问题(目前发布的状态下,如果在博客文章后面添加“.html”,它就可以工作,但这不应该是必要的)。 - marcanuy
在我的 _config.yml 文件中,永久链接被设置为 permalink: /:year/:month/:slug。我将其更改为 permalink: /:year/:month/:title.html,现在文章可以打开了。即使在关于页面添加了 permalink: /:title.html,我的关于页面似乎也没有生成 .html - WinterJules
解决了我的关于页面问题。感谢marcanuy。如果你没有指出.html永久链接,我就不会想到要检查_config.yml中的永久链接设置。 - WinterJules

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接