hugo-image-optimizer

command module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2023 License: GPL-3.0 Imports: 1 Imported by: 0

README

Hugo Image Optimizer

Quick and dirty image optimizer for Hugo based websites

Removes all unused images, converts the rest (png, jpg and gifs) to a compressed .webp format and updates all references in your posts.

Use Case

I often screw around with my blog, adding and changing images without much attention to size, weight or format. As a result, I end up with a bunch of unused images lying around and a less-than ideal performance.

This takes care of these issues without me having to worry about it.

Dependencies

Install

Either download the latest binary and add it to your $PATH or install it directly using go:

go install github.com/EricDriussi/hugo-image-optimizer@latest

Config

A optimizer.ini config file is expected and should look like this:

[dirs]
posts = content/posts/
images = static/images/
images_exclude = whoami donation

[compression]
quality = 50

This tells the optimizer where your posts and images are located (can be in subdirectories), what subdirectories to ignore when optimizing images, and how much compression to apply (0-100, 100 for max compression).

Add one to your website repo or in ~/.config/. Specify a different path with --config.

If no config file is provided, it will default to the values above.

Run

Either run it from your website directory or use the --website-path flag to specify the desired path.

Run optimize --help to check out the available commands and flags.

You can run them all at once with optimize or separately with optimize [CMD] for more fine-grained control.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL