Hugo-Encryptor is a tool to protect your Hugo posts. It uses AES-256 to encrypt the contents of your posts, and inserts a snippet of <script>
code to verify whether the password is correct or not in readers' browser. Without a correct key, nobody can decrypt your private posts.
Environmental dependence: Python3
$ git clone https://github.com/Li4n0/hugo_encryptor.git
$ cd hugo_encryptor
$ chmod +x hugo-encryptor.py
$ pip install -r requirements.txt
$ ln -s /absolute/path/to/hugo_encryptor/hugo-encryptor.py hugo-encryptor.py
$ mkdir -p /path/to/your/blog/layouts/shortcodes
$ ln -s /absolute/path/to/hugo_encryptor/shortcodes/hugo-encryptor.html /path/to/your/blog/layouts/shortcodes/hugo-encryptor.html
Notice: Some text are required before you actually start the encrypting part, with a tag <!--more-->
placed in the middle of them. Example:
---
title: "An Encrypted Post"
---
Some text is required to be placed here.
<!--more-->
{{% hugo-encryptor "PASSWORD" %}}
# You cannot see me unless you've got the password!
This is the content you want to encrypt!
**Do remember to close the `hugo-encryptor` shortcodes tag:**
{{% /hugo-encryptor %}}
It may be something like:
$ hugo
Notice: You may remove the
public/
directory before re-generate it, see #15 for details.
$ python /absolute/path/to/hugo_encryptor/hugo-encryptor.py
Then all the private posts in your public
directory would be encrypted thoroughly, congrats!
Though Hugo-Encryptor can run without any configurations, if you like, you can configure it (hmm.. slightly).
[params]
hugoEncryptorLanguage = "zh-cn" # within ["zh-cn", "zh-cn"]
Hugo-Encryptor has no any css but has left some class name for you to design your own style. Take a look at shortcodes/hugo-encryptor.html ;-)
-
Do remember to keep the source code of your encrypted posts private. Never push your blog directory into a public repository.
-
Every time when you generate your site, you should run
python hugo-encryptor
again to encrypt the posts which you want to be protected. If you are worried about you will forgot that, it's a good idea to use a shell script to take the place ofhugo
,such as below:
#!/bin/bash
hugo -D
python /absolute/path/to/hugo_encryptor/hugo_encryptor.py
rsync -a public remote@example.com:/