htmlxmljekyllsitemapjekyll-extensions

jekyll-sitemap and robots.txt get wrapped in html unexpectedly when generating jekyll site


My sitemap.xml and robots.txt, generated by jekyll-sitemap, get wrapped in html for some reason, which makes them non-compliant.

I'm using the jekyll-sitemap plugin, verified, that it is the latest version (https://github.com/jekyll/jekyll-sitemap) and tried a number of other things, mostly various ways of setting layout: none via front matter and conf.

If I create a random text or xml file, they do not end up being wrapped in html.

I also tried to disable all the plugins and default layout settings as well as the compress layout, but cannot find the cause for this.

Did someone come across such an issue? Any ideas how to debug this?

sitemap.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>

[EDIT] When I do create a random file with frontmatter it does get wrapped, even when I add layout: none.


Solution

  • I found out that this happens in conjunction with the jekyll-external-links plugin (https://github.com/riboseinc/jekyll-external-links). When deactivating jekyll-external-links in the Gemfile, jekyll-sitemap produces the robot.txt and sitemap.xml files without error.

    There is a fork of jekyll-external-links, that addresses this issue: https://github.com/Rp70/jekyll-external-links

    To use this for instead of the original you can replace the Gemfile entry of the original plugin with this line:

    gem 'jekyll-external-links', :git => 'https://github.com/Rp70/jekyll-external-links'

    This will pull in the forked repo and install the gem from there. The fork works as advertised and doesn't touch any non-html files, which is the source of the error.