I just shifted my entire blog from WordPress to Jekyll. There are still some pieces that need fixing here and there, but I am facing this problem at the moment. I am unable to generate sitemaps in Jekyll. I saw that there are a couple of plugins which can do the work for me.
Information on the site:
It would be great if you I could get some pointers towards how to do the required.
Note: This question is not the same as it's predecessors. I am not looking for options which use _site
.
As explained by John Day in this article, you can create a sitemap.xml
file in the site's root with this content:
---
layout: nil
title : "Sitemap"
sitemap_exclude: y
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for post in site.posts %}
<url>
<loc>{{site.production_url}}{{ post.url | remove: 'index.html' }}</loc>
</url>
{% endfor %}
{% for page in site.pages %}
{% if page.sitemap_exclude != 'y' %}
<url>
<loc>{{site.production_url}}{{ page.url | remove: 'index.html' }}</loc>
</url>
{% endif %}
{% endfor %}
</urlset>
In _config.yml
, define a variable named production_url
with the site's full base URL (e.g. http://example.com
).
If you want to exclude any links from the sitemap, include sitemap_exclude: y
in the front matter of the page or post.
For a more advanced example refer to this article: Building a Better Sitemap.xml with Jekyll.
You could create a new file in your site root called 'sitemap.xml', and within that page use liquid tags to iterate over all pages and posts extracting the necessary data. Seems like that would do the job pretty easily, assuming that you just want to generate a page which lists every page on the site in an xml format that conforms to the appropriate standard.
Just came across this because my site is hosted on github-pages. It seems github pages now supports this.
Just had to add to _config.yml:
gems:
- jekyll-sitemap
(You can optionally add to your Gemfile, but mine was already included via dependency)
(fun fact: jekyll-redirect-from is also supported by github pages)
You can not automagically generate a full sitemap in jekyll without using plugins.
What you could do is make your own ruby (or else) script that generates a sitemap as JSON data and then insert it in your config.yml. From there you could access that data from jekyll and display it.
But there is no built-in way to do that just with jekyll.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With