# Template Cookbook URL: /docs/theming/recipes/ Section: recipes Tags: cookbook, templates, jinja, examples -------------------------------------------------------------------------------- Template Cookbook Practical examples showing how to accomplish common tasks with Bengal's templating system. Content Queries Work with pages, sections, and taxonomies. Example What You'll Learn List Recent Posts where, sort_by, limit filters Group by Category group_by filter, nested loops Filter by Multiple Tags Chaining filters, in operator Page Features Add features to individual pages. Example What You'll Learn Add Table of Contents page.toc, scroll highlighting Show Reading Time reading_time filter Quick Reference The Essentials 1 2 3 4 5 6 7 8 9 10 11 12 13 14{# Get pages from a section #} {% set posts = site.pages | where('section', 'blog') %} {# Sort by date, newest first #} {% set recent = posts | sort_by('date', reverse=true) %} {# Limit to 5 #} {% set latest = recent | limit(5) %} {# Or chain it all #} {% set latest = site.pages | where('section', 'blog') | sort_by('date', reverse=true) | limit(5) %} Common Filters Filter Purpose Example where Filter by field pages \| where('draft', false) sort_by Sort results pages \| sort_by('title') limit Take first N pages \| limit(10) group_by Group by field pages \| group_by('category') first Get first item pages \| first See Template Functions for the complete reference. -------------------------------------------------------------------------------- Metadata: - Author: lbliii - Word Count: 200 - Reading Time: 1 minutes