问题描述
我的由 jekyll-sitemap 生成的 sitemap.xml 和 robots.txt 由于某种原因被包裹在 html 中,这使得它们不合规。
我正在使用 jekyll-sitemap 插件,经过验证,它是最新版本 (https://github.com/jekyll/jekyll-sitemap) 并尝试了许多其他方法,主要是通过前端设置 layout: none
的各种方法和确认。
如果我创建一个随机的文本或 xml 文件,它们最终不会被包装在 html 中。
我还尝试禁用所有插件和默认布局设置以及 compress
布局,但找不到原因。
有人遇到过这样的问题吗?任何想法如何调试?
站点地图.xml:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<?xml version="1.0" encoding="UTF-8"?><html><body>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
...
actual sitemap goes here
...
</body></html>
[编辑] 当我创建一个随机文件 with frontmatter 时,它确实会被包裹,即使我添加了 layout: none
。
解决方法
我发现这与 jekyll-external-links 插件 (https://github.com/riboseinc/jekyll-external-links) 一起发生。取消激活 Gemfile 中的 jekyll-external-links 时,jekyll-sitemap 会正确生成 robots.txt 和 sitemap.xml 文件。