A Liquid Tag to generate an HTML nested list site map from the pages array.
This is a work in progress, I may expand it with some additional navigation generation features, but for now it creates a nested sitemap from all Pages in a Jekyll site. It does not currently include Posts.
- Copy the
jekyll-sitemap-tag.rb
file to your jekyll_plugins
directory. - Use the tag on your sitemap page.
Add the render_sitemap
Liquid Tag to the desired page. given the following Pages:
- /index.html title="Home"
- /about.html title="About"
- /sitemap.html title="Sitemap"
- /2014/index.html title="Yearly Archive for 2014"
- /2014/09/index.html title="Monthly Archive for 2014/09"
{% render_sitemap %}
The tag will render the following:
<ul>
<li><a href="/index.html">Home</a>
<ul>
<li><a href="/about.html">About</a></li>
<li><a href="/sitemap.html">Sitemap</a></li>
<li><a href="/2014/index.html">Yearly Archive for 2014</a>
<ul>
<li><a href="/2014/09/index.html">Monthly Archive for 2014/09</a></li>
</ul>
</li>
</ul>
</li>
</ul>
or as rendered:
{% render_sitemap sitemap\.html %}
Where sitemap\.html
is a String that will be converted to a Ruby Regexp using the Regexp.new(string)
method.
The tag will render the following:
<ul>
<li><a href="/index.html">Home</a>
<ul>
<li><a href="/about.html">About</a></li>
<li><a href="/2014/index.html">Yearly Archive for 2014</a>
<ul>
<li><a href="/2014/09/index.html">Monthly Archive for 2014/09</a></li>
</ul>
</li>
</ul>
</li>
</ul>
or as rendered:
This tag expects every node in the sitemap/url structure to render correctly, so if you don't have an index page in a folder and you have folder listings disabled on your web server, the link will result in a denied page or 404 page.
If you'd like your own yearly/monthly indexes like my examples, checkout out my Jekyll Temporal Archive Generator project.