|
@@ -1,50 +1,74 @@
|
|
-# Hugo Encrypt
|
|
|
|
|
|
+# hugo-encrypt
|
|
|
|
|
|
`hugo-encrypt` is a golang port of [Hugo Encryptor](https://github.com/Li4n0/hugo_encryptor)
|
|
`hugo-encrypt` is a golang port of [Hugo Encryptor](https://github.com/Li4n0/hugo_encryptor)
|
|
|
|
|
|
`hugo-encrypt` is a tool that encrpyts content in your [Hugo](https://gohugo.io) posts. It uses AES-256-GCM to encrypt the contents of your posts, and inserts the necessary javascript code into the encrypted posts that decrypts the content after the correntc passphrase has been entered.
|
|
`hugo-encrypt` is a tool that encrpyts content in your [Hugo](https://gohugo.io) posts. It uses AES-256-GCM to encrypt the contents of your posts, and inserts the necessary javascript code into the encrypted posts that decrypts the content after the correntc passphrase has been entered.
|
|
|
|
|
|
-## Installation
|
|
|
|
|
|
+## Installation and Usage
|
|
|
|
|
|
-Environmental dependency: go 1.11+
|
|
|
|
|
|
+**Option A) Build**
|
|
|
|
|
|
-**Step 1: Install hugo-encrypt.**
|
|
|
|
|
|
+Requirements: go 1.11+
|
|
|
|
+
|
|
|
|
+**Step 1: Install `hugo-encrypt`.**
|
|
|
|
|
|
$ go get github.com/Izumiko/hugo-encrypt
|
|
$ go get github.com/Izumiko/hugo-encrypt
|
|
|
|
|
|
-**Step 2: Place `hugo-encrypt` in the root directory of your blog, or add `hugo-encrypt` to your `$PATH`**
|
|
|
|
|
|
+**Step 2: Place `shortcodes/hugo-encrypt.html` in the shortcode directory of your blog:**
|
|
|
|
+
|
|
|
|
+ $ mkdir -p /path/to/your/blog/layouts/shortcodes
|
|
|
|
+ $ cp shortcodes/hugo-encrypt.html /path/to/your/blog/layouts/shortcodes/hugo-encrypt.html
|
|
|
|
|
|
- $ cp hugo-encrypt /path/to/your/blog/
|
|
|
|
|
|
+**Step 3: Merge i18n translation files and/or add your own language.**
|
|
|
|
+
|
|
|
|
+ $ cp -r i18n /path/to/your/blog/
|
|
|
|
|
|
- or
|
|
|
|
|
|
+**Step 4: Use hugo-encrypt to encrypt content
|
|
|
|
|
|
$ export PATH=/path/to/hugo-encrypt/:$PATH
|
|
$ export PATH=/path/to/hugo-encrypt/:$PATH
|
|
|
|
+ $ hugo-encrypt -sitePath /path/to/hugo/public
|
|
|
|
|
|
-**Step 3: Place `shortcodes/hugo-encryptor.html` in the shortcode directory of your blog:**
|
|
|
|
|
|
+**Option B) Use docker
|
|
|
|
|
|
- $ mkdir -p /path/to/your/blog/layouts/shortcodes
|
|
|
|
- $ cp shortcodes/hugo-encryptor.html /path/to/your/blog/layouts/shortcodes/hugo-encryptor.html
|
|
|
|
|
|
+Requirements: docker
|
|
|
|
|
|
-**Step 4: Merge i18n translation files and/or add your own language.**
|
|
|
|
|
|
+ $ docker run -it --rm \
|
|
|
|
+ -v /path/to/hugo/public:/data/site \
|
|
|
|
+ chaosbunker/hugo-encrypt hugo-encrypt -sitePath /data/site`
|
|
|
|
|
|
- $ cp -r i18n /path/to/your/blog/
|
|
|
|
|
|
+## Using the `{{< hugo-encrypt >}}` tag in your blog posts
|
|
|
|
|
|
-## Usage
|
|
|
|
|
|
+**Option 1: Setting the password in your blogs config file**
|
|
|
|
|
|
-**Step 1: Use the `hugo-encryptor` tag around the text you want to encrypt **
|
|
|
|
|
|
+```
|
|
|
|
+[params]
|
|
|
|
+ password = "yourpassword"
|
|
|
|
+```
|
|
|
|
|
|
```markdown
|
|
```markdown
|
|
---
|
|
---
|
|
title: "This Is An Encrypted Post"
|
|
title: "This Is An Encrypted Post"
|
|
---
|
|
---
|
|
|
|
|
|
-{{< hugo-encryptor .Site.Params.Password >}}
|
|
|
|
|
|
+{{< hugo-encrypt >}}
|
|
|
|
+
|
|
|
|
+This content will be encrypted!
|
|
|
|
+
|
|
|
|
+{{< /hugo-encrypt >}}
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+**Option 2: Setting a spexcific password in the shortcode**
|
|
|
|
+
|
|
|
|
+```markdown
|
|
|
|
+---
|
|
|
|
+title: "This Is An Encrypted Post"
|
|
|
|
+---
|
|
|
|
|
|
-# You cannot see me unless you've got the passphrase!
|
|
|
|
|
|
+{{< hugo-encrypt "anotherpassword" >}}
|
|
|
|
|
|
-This is the content you want to encrypt!
|
|
|
|
|
|
+This content will also be encrypted!
|
|
|
|
|
|
-{{< /hugo-encryptor >}}
|
|
|
|
|
|
+{{< /hugo-encrypt >}}
|
|
```
|
|
```
|
|
|
|
|
|
**Step 2: Generate your site as usual**
|
|
**Step 2: Generate your site as usual**
|
|
@@ -98,12 +122,12 @@ Use i18n to display content generated by `hugo-Encrypt` in the language of your
|
|
|
|
|
|
* Remember to keep the source files of your encrypted posts private. Never push your blog directory into a public repository as the encryption happens after generating the html files with `hugo`.
|
|
* Remember to keep the source files of your encrypted posts private. Never push your blog directory into a public repository as the encryption happens after generating the html files with `hugo`.
|
|
|
|
|
|
-* Remember to run `hugo-encrypt` every time after generating your site with `hugo` to encrypt the posts you want to be passphrase-protected. You might want to use a shell script instead of `hugo` to take care of both generation and encryption of your html files:
|
|
|
|
|
|
+* Remember to run `hugo-encrypt` after generating your site with `hugo` to encrypt the posts you want to be passphrase-protected. You might want to use a shell script instead of `hugo` to take care of both steps:
|
|
|
|
|
|
```bash
|
|
```bash
|
|
#!/bin/bash
|
|
#!/bin/bash
|
|
|
|
|
|
- hugo
|
|
|
|
|
|
+ hugo --cleanDestinationDir
|
|
hugo-encrypt
|
|
hugo-encrypt
|
|
```
|
|
```
|
|
|
|
|