Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ How To Use:
3. In your config file, change `sitemap: file:` if you want your sitemap to be called something other than sitemap.xml.
4. Change the `sitemap: exclude:` list to exclude any pages that you don't want in the sitemap.
5. Change the `sitemap: include_posts:` list to include any pages that are looping through your posts (e.g. "/index.html", "/notebook/index.md", etc.). This will ensure that right after you make a new post, the last modified date will be updated to reflect the new post.
6. Run Jekyll: `jekyll build` to re-generate your site.
7. A `sitemap.xml` should be included in your _site folder.
6. Set an optional sitemap: change_frequency_default: that will set the change frequency if you haven't specified one in your individual page.
7. Run Jekyll: `jekyll build` to re-generate your site.
8. A `sitemap.xml` should be included in your _site folder.

Configuration defaults:

Expand Down
9 changes: 5 additions & 4 deletions sitemap_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def generate(site)
@config['priority_name'] = sitemap_config['priority_name'] || PRIORITY_NAME
@config['exclude'] = sitemap_config['exclude'] || EXCLUDE
@config['include_posts'] = sitemap_config['include_posts'] || INCLUDE_POSTS
@config['change_frequency_default'] = sitemap_config['change_frequency_default'].downcase if sitemap_config['change_frequency_default']

sitemap = REXML::Document.new << REXML::XMLDecl.new("1.0", "UTF-8")

Expand Down Expand Up @@ -126,7 +127,7 @@ def fill_posts(site, urlset)
def fill_pages(site, urlset)
site.pages.each do |page|
if !excluded?(site, page.path_to_source)
if File.exists?(page.path)
if File.exists?(File.join(site.source, page.path))
url = fill_url(site, page)
urlset.add_element(url)
end
Expand All @@ -149,9 +150,9 @@ def fill_url(site, page_or_post)



if (page_or_post.data[@config['change_frequency_name']])
if (page_or_post.data[@config['change_frequency_name']] || @config['change_frequency_default'])
change_frequency =
page_or_post.data[@config['change_frequency_name']].downcase
(page_or_post.data[@config['change_frequency_name']] || @config['change_frequency_default']).downcase

if (valid_change_frequency?(change_frequency))
changefreq = REXML::Element.new "changefreq"
Expand Down Expand Up @@ -192,7 +193,7 @@ def fill_location(site, page_or_post)
# Returns lastmod REXML::Element or nil
def fill_last_modified(site, page_or_post)
lastmod = REXML::Element.new "lastmod"
date = File.mtime(page_or_post.path)
date = File.mtime(File.join(site.source, page_or_post.path))
latest_date = find_latest_date(date, site, page_or_post)

if @last_modified_post_date == nil
Expand Down