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
961 stars 135 forks source link

.html pages appearing in sitemap.xml as folders #206

Closed mwhouser closed 6 years ago

mwhouser commented 6 years ago

I have 2 .html files in my root folder that generate as .html by Jekyll. However, jekyll-sitemap is including them in sitemap.xml as folders.

Example 1:

File: /archives.html Jekyll Generates: /archives.html Sitemap.xml includes: /archives

Example 2:

File: /404.html Jekyll Generates: /404.html Sitemap.xml includes: /404

pathawks commented 6 years ago

https://github.com/jekyll/jekyll-sitemap/blob/d6de78cae1b536ce8d29371cb8587dda3832dcf3/lib/sitemap.xml#L22

I'm not sure how our plugin could be causing this. Is your repo public? I'd love to see a specific example.

mwhouser commented 6 years ago

My repo is not public. I just tried the following:

{% assign pages = site.html_pages %}
  {% for page in pages %}
<url>
    <loc>{{ page.url  }}</loc>
    {% if page.last_modified_at %}
    <lastmod>{{ page.last_modified_at | date_to_xmlschema }}</lastmod>
    {% endif %}
</url>
  {% endfor %}

and it looks like the page.url has /archives and /404 in it. So it's getting passed like that from Jekyll.

mwhouser commented 6 years ago

If you're still interested, I created a public repo here that shows it:

https://github.com/mwhouser/jekyll-test

pathawks commented 6 years ago

This seems like a bug in Jekyll. I don't know why nobody has previously reported this.

Please open an issue at jekyll/jekyll

ashmaroli commented 6 years ago

@mwhouser According to your test-repo, the culprit seems to be your permalink configuration. Changing it as following should fix your issue:

- permalink: /:year/:month/:title.html
+ permalink: /:year/:month/:title:output_ext
ashmaroli commented 6 years ago

The behavior was changed in https://github.com/jekyll/jekyll/commit/b6c283a4aee531a06ba6b3c9cde5e972889c7471 but the official documentation left as is..

mwhouser commented 6 years ago

@ashmaroli, changing my permalink fixed it for me. Thanks.