More Premium Hugo Themes Premium Jekyll Themes

Jekyll Include Cache

A Jekyll plugin to cache the rendering of Liquid includes

Jekyll Include Cache

A Jekyll plugin to cache the rendering of Liquid includes

Author Avatar Theme by benbalter
Github Stars Github Stars: 123
Last Commit Last Commit: Jun 8, 2022 -
First Commit Created: Dec 18, 2023 -
Jekyll Include Cache screenshot

Overview:

The Jekyll Include Cache is a plugin that helps improve the performance of Jekyll websites by caching the rendering of computationally expensive Liquid includes. By rendering the include once and reusing the output whenever it is called with the same arguments, the plugin can potentially speed up the build process of the site significantly.

Features:

  • Caching Liquid includes: The plugin caches the rendering of Liquid includes, such as sidebars or navigations, to avoid repetitive computations.
  • Improved build performance: By reusing the cached output of includes with the same arguments, the plugin can speed up the build process of Jekyll websites.
  • Easy integration: Adding the plugin to your site’s Gemfile and configuring it in the config file allows for simple integration with your existing Jekyll setup.

Installation:

To install and use the Jekyll Include Cache plugin, follow these steps:

  1. Add the following line to your site’s Gemfile:

    gem 'jekyll-include-cache'
    
  2. Add the following code snippet to your site’s config file (usually _config.yml):

    plugins:
      - jekyll-include-cache
    

    Note: If you are using a Jekyll version less than 3.5.0, use the gems key instead of plugins.

  3. Replace the syntax for including a Liquid file in your template. Change:

    {% include foo.html %}
    

    to:

    {% include_cached foo.html %}
    

    This will instruct Jekyll to use the cached version of the include.

  4. Make sure to pass all required variables to your include as arguments and reference them within the include using the include.variable syntax. For example:

    Good:

    In your template:

    {% assign foo = "bar" %}
    {% include_cached foo.html foo=foo %}
    

    In your include:

    {{/* include.foo */}}
    

    Bad:

    In your template:

    {% assign foo = "bar" %}
    {% include_cached foo.html %}
    

    In your include:

    {{/* page.foo */}}
    

    or

    {{/* foo */}}
    

Summary:

The Jekyll Include Cache plugin offers a solution for improving the performance of Jekyll websites by caching the rendering of computationally expensive Liquid includes. By following the installation steps and making necessary adjustments to include syntax and variable referencing, developers can achieve significant improvements in the build speed of their websites.