Jekyll Sitemap: Using the jekyll-sitemap Plugin
The jekyll-sitemap Gem: What It Does
The jekyll-sitemap gem is the official sitemap solution for Jekyll, maintained by the Jekyll team and used natively on GitHub Pages. Once installed, it automatically generates a sitemap.xml file at the root of your site every time Jekyll builds. It scans all your pages, posts, and collections and includes them — no manual configuration required for a basic setup.
The generated sitemap follows the standard XML Sitemap protocol. Each entry includes a <loc> (the absolute URL, built from your url setting in _config.yml) and a <lastmod> derived from the page's last_modified_at front matter field if present, or the file's modification time. It does not include changefreq or priority by default, which is fine — Google largely ignores those fields anyway.
Adding jekyll-sitemap to Your Gemfile
Open your Gemfile at the root of your Jekyll project and add the gem to the jekyll_plugins group. Then run bundle install to install it.
Next, register the plugin in your _config.yml. If you're using GitHub Pages, the plugin is whitelisted and active by default — you may still want to declare it explicitly for clarity.
The url key in _config.yml is critical. Without it, the sitemap will have empty or relative URLs — a fatal flaw that prevents Google from using it. Always set this to your production URL, including the protocol (https://) and without a trailing slash.
Excluding Pages from Your Sitemap
Not every page belongs in your sitemap. Thank you pages, 404 pages, tag archive pages, and admin pages should be excluded. There are two ways to exclude a page.
The first method is per-page front matter. Add sitemap: false to the YAML front matter of any page you want to exclude:
The second method is sitewide exclusion in _config.yml. Use the defaults key or the plugin's own exclude list. For entire directory paths, the defaults approach is cleaner:
Customizing lastmod from Git Commits
By default, jekyll-sitemap uses file modification time for lastmod when no front matter date is set. On CI/CD systems (GitHub Actions, Netlify), files are often checked out with the same timestamp, making lastmod meaningless. The better approach is to use the last_modified_at front matter field, which the plugin reads preferentially.
For a fully automated solution, use the jekyll-last-modified-at gem alongside jekyll-sitemap. It reads the actual git commit date for each file and populates last_modified_at automatically, giving you accurate lastmod values in your sitemap without touching front matter manually.
GitHub Pages Integration
GitHub Pages has a whitelist of safe Jekyll plugins it runs automatically. jekyll-sitemap is on that whitelist, which means if you're deploying directly to GitHub Pages (not via GitHub Actions), the plugin runs without any additional setup — you don't even need it in your Gemfile. Just declare it in plugins: in _config.yml and it will work.
If you're using GitHub Actions to build and deploy, you have full control over your Gemfile and can use any plugin. Run bundle exec jekyll build in your workflow, then deploy the _site/ output. Your sitemap.xml will be in the root of _site/ after a successful build.
Verifying Your Sitemap and Submitting to Google
After deploying, visit https://yourdomain.com/sitemap.xml to confirm it renders valid XML. Run a bundle exec jekyll build locally first and check _site/sitemap.xml to catch issues before deploying. Common problems include missing or incorrect url in _config.yml, pages appearing that should be excluded, and missing pages that exist but haven't been committed to git.
Once verified, submit to Google Search Console under Indexing > Sitemaps. Enter the path sitemap.xml (Google already knows your domain from the property). Also add a reference in your robots.txt: Sitemap: https://yourdomain.com/sitemap.xml. This helps other search engines like Bing and DuckDuckGo discover your sitemap automatically.