LogoTemplate0
Logo of Jekyll Compress HTML on template0.com

Jekyll Compress HTML

A Jekyll layout that compresses HTML in pure Liquid, reducing file size without plugins.

Introduction

Jekyll Compress HTML is a free, open-source Jekyll layout that compresses the HTML output of a Jekyll site using only Liquid, Jekyll's built-in templating language, requiring no additional plugins or Ruby gems. It was created by penibelst and is documented at jch.penibelst.de, with the source code hosted on GitHub and distributed through a releases page for download.

What is Jekyll Compress HTML?

Jekyll Compress HTML is a layout file used in Jekyll static sites to reduce the size of generated HTML. It takes the fully rendered HTML from the Jekyll build process and applies Liquid filters to strip unnecessary whitespace, blank lines, and HTML comments, producing a minified version of the page. It runs on any standard Jekyll installation, since it is written entirely in Liquid—the same language Jekyll uses for templates—and does not depend on any external minification library.

Because it is pure Liquid, it executes during Jekyll's normal generation step and adds no extra build passes. The author maintains a documentation site at jch.penibelst.de, which explains the layout's options and usage in detail. The GitHub repository uses Travis CI for continuous integration, indicated by a build status badge, and hosts the latest release for download.

What makes Jekyll Compress HTML stand out?
  • Pure Liquid implementation — The entire compression logic is written in Liquid tags and filters, meaning no JavaScript, Node.js, or Ruby gems like Nokogiri are required to run it; the only prerequisite is Jekyll itself.
  • Jekyll layout format — Installed by copying the compress.html file into your site's _layouts directory and referencing it in front matter or a default layout configuration, making integration straightforward for any Jekyll project.
  • HTML minification — Removes whitespace, line breaks, and comments from the rendered markup, shrinking file sizes and reducing the amount of data served to visitors.
  • GitHub Pages compatible — Because it uses only Liquid and no custom plugins, the layout works on GitHub Pages, which restricts users to standard Jekyll features and a whitelist of plugins; this makes HTML compression accessible on that platform.
  • Open source distribution — The project is released under an open-source license and is freely available from the GitHub repository, with a documentation site and release downloads.
  • Continuous integration — The repository is tested with Travis CI, as shown by the build status badge, indicating an active project that verifies its code.
Who should use Jekyll Compress HTML?

Jekyll site owners who want to reduce their site's HTML file size and improve page load performance by stripping redundant whitespace and comments. Web developers who build static sites with Jekyll and prefer a dependency-free solution that relies only on Liquid, avoiding the need to install or maintain Ruby minification gems. GitHub Pages users who cannot deploy custom Jekyll plugins and need a compression method that works within GitHub's supported feature set.

What can you do with Jekyll Compress HTML?
  • Performance optimization: Automatically shrink each page's HTML output during the Jekyll build, lowering bandwidth usage and potentially improving Core Web Vitals metrics related to payload size.
  • GitHub Pages publishing: Apply HTML compression to a site hosted on GitHub Pages without violating the platform's plugin restrictions, since the layout is implemented in Liquid.
  • Site-wide default formatting: Set the compress layout as your site's default in the configuration file so every page, post, and collection is compressed automatically.
How does Jekyll Compress HTML work?

The layout wraps your site's content, and when Jekyll renders a page, Liquid processes the compress.html layout. The layout's Liquid code strips out tabs, spaces, newlines, and HTML comments from the generated markup, then outputs the compressed result. To use it, you download the layout, place it in your _layouts directory, and assign it as the layout for the pages you want compressed; the documentation explains any available tuning options.

FAQ
Is Jekyll Compress HTML free to use?

Yes, it is open source and available for free. The source code is hosted on GitHub, and you can download the latest release from the project's releases page. No license fees or subscriptions are required.

Does Jekyll Compress HTML work on GitHub Pages?

Yes, it is compatible with GitHub Pages because the layout is written entirely in Liquid and does not rely on custom plugins, which GitHub Pages does not support. You can place the layout in your repository and use it within the standard Jekyll build that GitHub Pages runs.

How do I install Jekyll Compress HTML?

Download the compress.html file from the GitHub releases page and copy it into your Jekyll site's _layouts directory. Then set the compression layout as the default layout in your _config.yml file or in individual pages' front matter to start compressing HTML output.

What exactly does the compression remove?

The layout removes unnecessary whitespace (including indentation and extra blank lines) and HTML comments from the rendered page. This reduces the file size without changing the visible content, but you should review the documentation for any specifics regarding elements like preformatted text where whitespace can be meaningful.

screenshot of Jekyll Compress HTML on template0.com

Information

GitHub Info

  • Stars602
  • Last maintained2024/05/09
  • LicenseMIT
  • Primary languageHTML

Categories

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates