Minifies HTML files generated by Pelican
Project description
pelican-htmlmin
A Pelican plugin that uses htmlmin to remove comments and extra whitespace from your website after the pages have been generated.
Turning this:
<html>
<head>
<title> Hello, World! </title>
</head>
<body>
<p> How <em>you</em> doing? </p>
</body>
</html>
Into this:
<html><head><title>Hello, World!</title><body><p> How <em>you</em> doing? </p></body></html>
Installing
pelican-htmlmin
, is available on pip:
$ pip install pelican-htmlmin
After you’ve installed the package, update the PLUGINS
variable in your
pelicanconf.py
to include the package in the next pelican build.
PLUGINS = [
# ...
'pelican_htmlmin',
# ...
]
Options
Being a very small wrapper around htmlmin
, there are only a few options
that you may need.
HTMLMIN_ENABLED
If Pelican is in DEBUG
mode, pelican-htmlmin
will not minify
files to help with debugging. You only need to set
HTMLMIN_ENABLED = True
if you want to minify your HTML files while
DEBUG
is set.
# minify generated files only if pelican is not in DEBUG mode
HTMLMIN_ENABLED = not logger.getEffectiveLevel() == logging.DEBUG
HTMLMIN_MATCH
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?$'
HTMLMIN_OPTIONS
If you wish to pass arguments directly to htmlmin
, use the
HTMLMIN_OPTIONS
to pass keyword arguments.
HTMLMIN_OPTIONS = {
'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
Contributing
Please feel free to help. Issues, pull requests, and patches via email, all are warmly welcomed.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pelican_htmlmin-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70a128648238973ec46cc1279cdd400e8082905ac3e76274dade1c3149dc67ac |
|
MD5 | d290d12dec5462821c4fdf69e1e1b5c5 |
|
BLAKE2b-256 | f07e6f4f1521298eb49d231b78beab02eb79dfd129c3461b50fca588dd1a588d |