HK Freelance Developer

Minify Hugo Generated HTML

People have been asking for this for Hugo since 30 Aug 2014, but it is unlikely having the official support any time soon.

However, it can be easily archived by using Gulp and some scripts. You can see the result from the source of this blog.

Here is the gist, which you can copy into the root directory of your Hugo website:

{{< gist ratson 3fa6ed459c6770f02767 >}}

Then you should run the following commands to build the website with minified HTML files:

npm install
npm run build