ruby-on-railsjekyllgithub-pagesjekyll-extensions

Jekyll sitemap not being generated on Github Pages, but generates locally


Running bundle exec jekyll serve on my local machine builds the site, and I can find the sitemap normally at localhost:4000/sitemap.xml (meaning it is definitely inside the _site directory).

However, after pushing the site to Github Pages, I can't find sitemap.xml, at least not in the root directory.

Gemfile:

# frozen_string_literal: true

source "https://rubygems.org"
gem 'github-pages', group: :jekyll_plugins
gem 'jekyll-sitemap'
gem "webrick", "~> 1.7"

_config.yml:

# Build settings
theme: jekyll-theme-midnight
plugins:
  - jekyll-feed
  - jekyll-remote-theme
  - jekyll-sitemap


Solution

  • Just tested it in my project and it works. Try to move the gem into :jekyll_plugins group. Here is my Gemfile:

    # 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", "~> 226", group: :jekyll_plugins
    # If you have any plugins, put them here!
    group :jekyll_plugins do
      gem "jekyll-feed", "~> 0.12"
      gem 'jekyll-sitemap'
    end
    

    But it also worked without putting it into the group, as described in the docs