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

Posts getting duplicated in generated sitemap #233

Closed aamnakhan closed 5 years ago

aamnakhan commented 5 years ago

Hey! I see this was a problem earlier and it was fixed but I think it's crept back in? This is what my sitemap looks like. Same issue as #99 and #91

<?xml version="1.0" encoding="UTF-8"?>
<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">
<url>
<loc>http://localhost:4000/2018-01-21-hello-world</loc>
<lastmod>2019-01-21T00:00:00+05:30</lastmod>
</url>
<url>
<loc>http://localhost:4000/2018-01-25-hello-world</loc>
<lastmod>2019-01-24T00:00:00+05:30</lastmod>
</url>
<url>
<loc>http://localhost:4000/2018-01-21-hello-world</loc>
</url>
<url>
<loc>http://localhost:4000/2018-01-25-hello-world</loc>
</url>
<url>
<loc>http://localhost:4000/about</loc>
</url>
<url>
<loc>http://localhost:4000/</loc>
</url>
</urlset>
ashmaroli commented 5 years ago

@aamnakhan Please ensure that you provide us with as much information as possible when reporting bugs. For example,

aamnakhan commented 5 years ago

Apologies. Here you go

Ruby version - ruby-2.5.0 Plugin version - jekyll-sitemap-1.2.0 Jekyll version - jekyll 3.7.4 Using gitpages

My config file

title: Tiny Bits Of Carbon
description: >- # this means to ignore newlines until "baseurl:"
  A blog about a lot of things that possibly amount to nothing
baseurl: "" # the subpath of your site, e.g. /blog
logo: /assets/images/carbon.svg
url: "https://tinybitsofcarbon.com" # the base hostname & protocol for your site, e.g. http://example.com
name: Aamna
twitter_username: _aamnakhan
github_username:  aamnakhan
og_image: /assets/images/carbon.svg

#pagination
paginate: 2
paginate_path: "/page/:num/"

defaults:
 #posts
  - scope:
      path: ""
      type: posts
    values:
      layout: single
      comments: true
      share: true
      related: true
      signup: true
#pages
  - scope:
      path: ""
      type: pages
    values:
      layout: single

analytics:
  provider: "google-universal"
  google:
    tracking_id: "UA-44949721-3"
    anonymize_ip: false # default

# Build settings
markdown: kramdown
remote_theme: "mmistakes/minimal-mistakes"
minimal_mistakes_skin: contrast
locale: en
plugins:
  - jekyll-feed
  - jekyll-paginate
  - jekyll-remote-theme
  - jemoji
  - jekyll-sitemap
  - jekyll-gist
  - jekyll-include-cache

whitelist:
  - jekyll-feed
  - jekyll-paginate
  - jekyll-remote-theme
  - jemoji
  - jekyll-sitemap
  - jekyll-gist
  - jekyll-include-cache

include: ["_pages", "_posts"]

exclude: ['config.ru', 'Gemfile', 'Gemfile.lock', 'vendor']

My gemfile

source "https://rubygems.org"

# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
# gem "jekyll", "~> 3.8.5"
gem "github-pages", group: :jekyll_plugins

# This is the default theme for new Jekyll sites. You may change this to anything you like.
# gem "minimal-mistakes-jekyll"

# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
# gem "github-pages", group: :jekyll_plugins

# If you have any plugins, put them here!
group :jekyll_plugins do
  gem "jekyll-feed", "~> 0.6"
  gem "jekyll-paginate"
  gem "jekyll-remote-theme"
  gem "jemoji"
  gem "jekyll-sitemap"
  gem "jekyll-gist"
  gem "jekyll-include-cache"

end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]

# Performance-booster for watching directories on Windows
# gem "wdm", "~> 0.1.0" if Gem.win_platform?
ashmaroli commented 5 years ago

@aamnakhan The issue is with the incorrect usage of include configuration. You should not include _posts in the array. Posts are internally seen as a Collection and they get processed at all times as long as the filename follows the YYYY-MM-DD-TITLE format.