1 min read

How to encrypt content with Hugo

How to encrypt content with Hugo

Feelin' ______ today. Might delete l8er idk

I am using hugo for my blog (Update 22.09.20223: I am not using Hugo anymore), so I searched github if anyone already came up with a solution to encrypt/decrypt content with hugo. I found hugo-encrypt, a “port of hugo_encryptor in golang” and it was close to what I had in mind. I made a few changes and improvements, set up an automated build so I can use it in my drone pipeline and can now use the following shortcode to encrypt content:

{{% hugo-encrypt "passwd" %}}

This content is encrypted.

{{% /hugo-encrypt %}}

I can use a ‘per-post’ passphrase as shown in the example, or –if not set in the shortcode– use the default passphrase that I set in my config.toml.

[params.hugoEncrypt]
	password = "omgwtf"

For details on how to implement this refer to the readme of the repository.