Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty urlset with Jekyll 3.0.1 (using --source and --destination) #34

Open
nfagerlund opened this issue Jan 8, 2016 · 1 comment
Open

Comments

@nfagerlund
Copy link

Our sitemap has a urlset element, but it's now empty after upgrading to latest Jekyll and latest sitemap plugin. Jekyll 3.0.1, about a bazillion pages, zero posts. Our site builder runs Jekyll using the --source and --destination flags, and does not chdir into the source dir before running it.

Prying things open with byebug, it looks like the problem is here:

    def fill_pages(site, urlset)
      site.pages.each do |page|
        if !excluded?(site, page.path_to_source)
          if File.exists?(page.path)   # <-- RIGHT HERE
            url = fill_url(site, page)
            urlset.add_element(url)
          end
        end
      end
    end

The value of page.path is always something like "pe/2015.3/windows_config_mgmnt.md", and just calling File.exists? on it will only work if you've chdired into the source dir.

So I figure, instead of relying on an unreliable pwd, the generator should be prepending the value of site.source to each page.

And actually, come to think of it, why test for existence in the first place? Is there a situation where Jekyll would create and hold onto a page object without a source file?

@nfagerlund
Copy link
Author

Ack, there's other places in the code that make the same assumption. Just found one when I ripped out that check: date = File.mtime(page_or_post.path).

nfagerlund added a commit to nfagerlund/puppet-docs that referenced this issue Jan 8, 2016
The stock 3.x-compatible version of the sitemap plugin lets the site build...
but it doesn't actually generate a sitemap. The main urlset element is empty.

Filed kinnetica/jekyll-plugins#34
nfagerlund added a commit to nfagerlund/puppet-docs that referenced this issue Jan 8, 2016
kinnetica/jekyll-plugins#34

The underlying problem here is that the sitemap generator is assuming the source
dir is the pwd, and in our case it's not. This commit hardens it up a bit, so
it'll work no matter where you ran the jekyll command from.
nfagerlund added a commit to nfagerlund/puppet-docs that referenced this issue Jan 8, 2016
kinnetica/jekyll-plugins#34

The underlying problem here is that the sitemap generator is assuming the source
dir is the cwd, and in our case it's not. This commit hardens it up a bit, so
it'll work no matter where you ran the jekyll command from.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant