Whilst the Jekyll docs are great, there’s been a few things that I’ve wanted to do with Jekyll which weren’t obvious - hence this post which I’ll use to document (or link to) any useful Jekyll snippets I’ve found.
This is straightforward enough, and utilises the limit literal to show the top 10 posts sitewide:
Or the last 10 posts within a specific category:
Show all posts from the current month
It can be quite handy to show just the posts from the current month - for example a news section which shows recent posts:
Show all posts from the past 3 weeks
It can be useful to show all posts within N weeks (or days, or months etc etc). Whilst Jekyll is obviously a static-site generator (so the end HTML won’t magically update itself on your server!), if you use the following on a regularly-published page on your website, it’ll work well:
sitemap.xml file for SEO/search engine bots
It’s always handy to have a sitemap.xml file, linked to from your robots.txt file. Firstly, this can be submitted to Google’s Webmaster search console. Secondly, many bots who look at your robots.txt file will then follow through to your sitemap file too - which is another way of helping make your site SEO friendly.
The entire sitemap.xml file should be saved at the root of your Jekyll project (aka alongside your index.md and other main pages) and look as follows:
I’ll post more useful snippets as and when I come across them, so feel free to check back soon.