Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Minifies HTML files generated by Pelican

Project description


A Pelican plugin that uses htmlmin to remove comments and extra whitespace from your website after the pages have been generated.

Turning this:

    <title>  Hello, World!  </title>
    <p> How  <em>you</em> doing?  </p>

Into this:

<html><head><title>Hello, World!</title><body><p> How <em>you</em> doing? </p></body></html>


pelican-htmlmin, is available on pip:

$ pip install pelican-htmlmin

After you’ve installed the package, update the PLUGINS variable in your to include the package in your next pelican build.

    # ...
    # ...


Being a very small wrapper around htmlmin, there are only a few options that you may need.


By Default, if Pelican is in DEBUG mode, pelican-htmlmin will not minify any files, helping with debugging. To override this, set HTMLMIN_ENABLED = True to minify your HTML files regardless of the DEBUG flag.

# minify generated files only if pelican is not in DEBUG mode
HTMLMIN_ENABLED = not logger.getEffectiveLevel() == logging.DEBUG


pelican-htmlmin looks for files ending with .html or .htm to minify. You can use the HTMLMIN_MATCH to change the regular expression that matches the files you wish to minify.

HTMLMIN_MATCH = r'.html?$'


If you wish to pass arguments directly to htmlmin, use the HTMLMIN_OPTIONS to pass keyword arguments.

    'remove_comments': True,
    'remove_all_empty_space': True,
    'remove_optional_attribute_quotes': False

For more information on the arguments you can give htmlmin, see their documentation here


Please feel free to help. Buying me Beer, emailing issues, or patches via email, are all warmly welcomed, especially beer.

License: MIT

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pelican-htmlmin, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size pelican_htmlmin-1.0.2-py3-none-any.whl (3.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pelican-htmlmin-1.0.2.tar.gz (3.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page