Skip to content

Li4n0/hugo_encryptor

Repository files navigation

Hugo Encryptor

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.

中文文档

DEMO

Installation

Environmental dependence: Python3

Step 1: Install all the requirements of Hugo-Encryptor

$ git clone https://github.com/Li4n0/hugo_encryptor.git
$ cd hugo_encryptor
$ chmod +x hugo-encryptor.py
$ pip install -r requirements.txt

Step 2: Create a symlink (Optional)

$ ln -s /absolute/path/to/hugo_encryptor/hugo-encryptor.py hugo-encryptor.py

Step 3: Symlink shortcodes/hugo-encryptor.html into the shortcode directory of your blog:

$ 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

Usage

Step 1: Wrap the text you want to encrypt with the tag hugo-encryptor

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 %}}

Step 2: Generate your site as usual

It may be something like:

$ hugo

Notice: You may remove the public/ directory before re-generate it, see #15 for details.

Step 3: Get the encryption done!

$ python /absolute/path/to/hugo_encryptor/hugo-encryptor.py

Then all the private posts in your public directory would be encrypted thoroughly, congrats!

Configuration

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"]

Style

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 ;-)

Notice

  • 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 of hugo ,such as below:

#!/bin/bash

hugo -D
python /absolute/path/to/hugo_encryptor/hugo_encryptor.py
rsync -a public [email protected]:/

About

A tools for encrypting hugo posts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published