jekyll / jekyll-sitemap

Jekyll plugin to silently generate a sitemaps.org compliant sitemap for your Jekyll site
http://rubygems.org/gems/jekyll-sitemap
MIT License
949 stars 134 forks source link

sitemap is wrapped in html making it non-compliant #283

Closed cargocultprogramming closed 2 years ago

cargocultprogramming commented 3 years ago

Hi! Not sure how and why this is happening, but my sitemap gets wrapped in html. I tried a number of things in _config.yml like setting the default style to none, excluding all other plugins, even creating an empty sitemap.xml with frontmatter, but I always get sitemap.xml and robots.txt wrapped in html. Some more details here: https://stackoverflow.com/questions/67375027/jekyll-sitemap-and-robots-txt-get-wrapped-in-html-unexpectedly-when-generating-j

It's easy to correct manually after the build of course, but it's annoying that I cannot find the root cause for this.

cargocultprogramming commented 3 years ago

This issue is somehow cause by the jekyll-external-link plugin. Will try to resolve there.

jekyllbot commented 3 years ago

This issue has been automatically marked as stale because it has not been commented on for at least two months.

The resources of the Jekyll team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.

This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.

akhy commented 2 years ago

Just got caught in the same issue, but i'm not using jekyll-external-link.

I managed to get around it by adding a new custom plugin (e.g. plugins/fix-sitemap.rb to remove the html tags after all pages has been written to disk:

Jekyll::Hooks.register %i[pages], :post_write do |doc|
  if doc.name == 'sitemap.xml'
    path = doc.destination(doc.site.dest)
    content = File.read(path)
    content.gsub!('<html><body>', '')
    content.gsub!('</body></html>', '')
    File.write(path, content)
  end
end