Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/benbalter/jekyll-include-cache
A Jekyll plugin to cache the rendering of Liquid includes
https://github.com/benbalter/jekyll-include-cache
caching jekyll jekyll-plugin
Last synced: 1 day ago
JSON representation
A Jekyll plugin to cache the rendering of Liquid includes
- Host: GitHub
- URL: https://github.com/benbalter/jekyll-include-cache
- Owner: benbalter
- License: mit
- Created: 2016-12-19T18:40:35.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2024-06-11T14:34:41.000Z (8 months ago)
- Last Synced: 2025-01-24T14:08:17.411Z (8 days ago)
- Topics: caching, jekyll, jekyll-plugin
- Language: Ruby
- Homepage:
- Size: 68.4 KB
- Stars: 117
- Watchers: 6
- Forks: 33
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: docs/CONTRIBUTING.md
- Funding: .github/funding.yml
- License: LICENSE.md
- Code of conduct: docs/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: docs/SECURITY.md
Awesome Lists containing this project
README
# Jekyll Include Cache
*A Jekyll plugin to cache the rendering of Liquid includes*
[![CI](https://github.com/benbalter/jekyll-include-cache/actions/workflows/ci.yml/badge.svg)](https://github.com/benbalter/jekyll-include-cache/actions/workflows/ci.yml)
## What it does
If you have a computationally expensive include (such as a sidebar or navigation), Jekyll Include Cache renders the include once, and then reuses the output any time that includes is called with the same arguments, potentially speeding up your site's build significantly.
## Usage
1. Add the following to your site's Gemfile:
```ruby
gem 'jekyll-include-cache'
```2. Add the following to your site's config file:
```yml
plugins:
- jekyll-include-cache
```
💡 If you are using a Jekyll version less than 3.5.0, use the `gems` key instead of `plugins`.3. Replace `{% include foo.html %}` in your template with `{% include_cached foo.html %}`
## One potential gotcha
For Jekyll Include Cache to work, you cannot rely on the page context to pass variables to your include (e.g., `assign foo=bar` or `page.title`). Instead, you must explicitly pass all variables to the include as arguments, and reference them within the include as `include.foo` (instead of `page.foo` or just `foo`).
### Good
In your template:
```liquid
{% include_cached shirt.html size=medium color=red %}
```In your include:
```liquid
Buy our {{ include.color }} shirt in {{ include.size }}!
```### Bad
In your template:
```liquid
{% assign color=blue %}
{% include_cached shirt.html %}
```In your include:
```liquid
Buy our {{ color }} shirt in {{ page.size }}!
```