Encrypt Hugo Site using Staticrypt

When deploying to netlify, it’s recommended to setup your theme as a git submodule (but a zip should still work). To do that, run this locally then commit and push your changes.

git submodule add https://github.com/JugglerX/hugo-hero-theme themes/hugo-hero-theme

Do I delete my current theme files, then install as a git submodule?

Correct.

Now I’m getting another error:
8:26:12 AM: Build ready to start
8:26:14 AM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
8:26:14 AM: build-image tag: v3.3.2
8:26:14 AM: buildbot version: 75cd99f62ada9e21edea53208e8baf0eab85a045
8:26:14 AM: Fetching cached dependencies
8:26:14 AM: Failed to fetch cache, continuing with build
8:26:14 AM: Starting to prepare the repo for build
8:26:14 AM: No cached dependencies found. Cloning fresh repo
8:26:14 AM: git clone https://github.com/edcous/leahdemo
8:26:15 AM: Preparing Git Reference refs/heads/master
8:26:17 AM: Found netlify.toml. Overriding site configuration
8:26:17 AM: Different build command detected, going to use the one specified in the toml file: 'hugo && npm install && find . -type f -name “*.html” -exec staticrypt {} mypassword ’ versus ‘hugo’ in the site
8:26:17 AM: Starting build script
8:26:17 AM: Installing dependencies
8:26:18 AM: Downloading and installing node v10.16.0…
8:26:19 AM: Downloading https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz
8:26:19 AM:

8:26:19 AM: 2.2%
8:26:19 AM:
########## 14.4%
8:26:19 AM:
######################################################################## 100.0%
8:26:19 AM: Computing checksum with sha256sum
8:26:19 AM: Checksums matched!
8:26:22 AM: Now using node v10.16.0 (npm v6.9.0)
8:26:22 AM: Attempting ruby version 2.6.2, read from environment
8:26:23 AM: Using ruby version 2.6.2
8:26:24 AM: Using PHP version 5.6
8:26:24 AM: Started restoring cached node modules
8:26:24 AM: Finished restoring cached node modules
8:26:24 AM: Installing NPM modules using NPM version 6.9.0
8:26:27 AM: added 55 packages from 18 contributors and audited 72 packages in 1.42s
8:26:27 AM: found 0 vulnerabilities
8:26:27 AM: NPM modules installed
8:26:27 AM: Installing Hugo 0.55.6
8:26:28 AM: Hugo Static Site Generator v0.55.6-A5D4C82D2/extended linux/amd64 BuildDate: 2019-05-18T08:08:34Z
8:26:28 AM: Started restoring cached go cache
8:26:28 AM: Finished restoring cached go cache
8:26:28 AM: unset GOOS;
8:26:28 AM: unset GOARCH;
8:26:28 AM: export GOROOT=’/opt/buildhome/.gimme/versions/go1.12.linux.amd64’;
8:26:28 AM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
8:26:28 AM: go version >&2;
8:26:28 AM: export GIMME_ENV=’/opt/buildhome/.gimme/env/go1.12.linux.amd64.env’;
8:26:28 AM: go version go1.12 linux/amd64
8:26:28 AM: Installing missing commands
8:26:28 AM: Verify run directory
8:26:28 AM: Executing user command: hugo && npm install && find . -type f -name “*.html” -exec staticrypt {} mypassword
8:26:28 AM: Building sites …
8:26:28 AM: | EN
8:26:28 AM: ±-----------------±—+
8:26:28 AM: Pages | 20
8:26:28 AM: Paginator pages | 0
8:26:28 AM: Non-page files | 0
8:26:28 AM: Static files | 21
8:26:28 AM: Processed images | 0
8:26:28 AM: Aliases | 0
8:26:28 AM: Sitemaps | 1
8:26:28 AM: Cleaned | 0
8:26:28 AM: Total in 205 ms
8:26:30 AM: audited 72 packages in 0.887s
8:26:30 AM: found 0 vulnerabilities
8:26:30 AM: find: missing argument to `-exec’
8:26:30 AM: Skipping functions preparation step: no functions directory set
8:26:30 AM: Caching artifacts
8:26:30 AM: Started saving node modules
8:26:30 AM: Finished saving node modules
8:26:30 AM: Started saving pip cache
8:26:30 AM: Finished saving pip cache
8:26:30 AM: Started saving emacs cask dependencies
8:26:30 AM: Finished saving emacs cask dependencies
8:26:30 AM: Started saving maven dependencies
8:26:30 AM: Finished saving maven dependencies
8:26:30 AM: Started saving boot dependencies
8:26:30 AM: Finished saving boot dependencies
8:26:30 AM: Started saving go dependencies
8:26:30 AM: Finished saving go dependencies
8:26:33 AM: Error running command: Build script returned non-zero exit code: 1
8:26:33 AM: Failing build: Failed to build site
8:26:33 AM: failed during stage ‘building site’: Build script returned non-zero exit code: 1
8:26:33 AM: Finished processing build request in 18.965706827s
8:26:33 AM: Shutting down logging, 0 messages pending
What is happening now?

Relevant line:

8:26:30 AM: find: missing argument to `-exec’

I got that find command from the example usages at staticrypt - npm

So run it and see if it works locally. Then you can go from there

What command do I run on my computer, and where do I run it? Also, do I need a package.json file?

The full find command listed in the above link.

Yes. And you’ll need staticrypt added as a dependency.

In what directory do I run it (Main Site Directory, public?)? And having it installed in the folder of my hugo site works, right?

Yep, public dir.

That works. Installing globally will also work.

Didn’t work, here is the command I used:
C:\Hugo\Sites\ \public>find . -type f -name “*.html” -exec staticrypt {} test ;
Access denied - .
File not found - -TYPE
File not found - F
File not found - -NAME
File not found - -EXEC
File not found - STATICRYPT
File not found - {}
File not found - TEST
File not found - ;

P.S. I also found this, don’t know if this is helpful: https://github.com/robinmoisson/staticrypt/issues/110

You’re getting an error because you’re running that command on Windows. It’s only available on Mac/Linux/Unix. So if you want to run it locally, (1) install Git Bash, or (2) install Windows Subsystem for Linux.

And yep that GitHub issue is relevant.

Download https://git-scm.com/download/win

Then after installing it, open Git Bash.

Just realized, I already have it.

It couldn’t find the command

What error did you get?

User@Eli-PC MINGW64 ~ (master)
$ C:\Hugo\Sites\leahdemo\public>find . -type f -name “*.html” -exec staticrypt {} test ;
bash: C:HugoSitesleahdemopublic: command not found

User@Eli-PC MINGW64 ~ (master)
$ Access denied - .
bash: Access: command not found

User@Eli-PC MINGW64 ~ (master)
$ File not found - -TYPE
File: unknown option – T
File: unknown option – Y
File: Unknown param E

User@Eli-PC MINGW64 ~ (master)
$ File not found - F
not: cannot open not' (No such file or directory) found: cannot openfound’ (No such file or directory)
File not found - -NAME
/dev/stdin: ASCII text
F: cannot open `F’ (No such file or directory)

User@Eli-PC MINGW64 ~ (master)
$ File not found - -EXEC
File: unknown option – X
Usage: File [-bcCdEhikLlNnprsvzZ0] [–apple] [–extension] [–mime-encoding]
[–mime-type] [-e ] [-F ] [-f ]
[-m ] [-P <parameter=value>] …
File -C [-m ]
File [–help]

User@Eli-PC MINGW64 ~ (master)
$ File not found - STATICRYPT
not: cannot open not' (No such file or directory) found: cannot openfound’ (No such file or directory)
File not found - {}
/dev/stdin: ASCII text
STATICRYPT: cannot open `STATICRYPT’ (No such file or directory)

User@Eli-PC MINGW64 ~ (master)
$ File not found - TEST
not: cannot open not' (No such file or directory) found: cannot openfound’ (No such file or directory)
File not found - ;
/dev/stdin: ASCII text
TEST: cannot open `TEST’ (No such file or directory)

U

Hmm. So here’s how I’d do it:

(1) Navigate to your public dir

cd /c/Hugo/Sites/leahdemo/public

(2) Then run that find command

When I use this command: find . -type f -name \"*.html\" -exec staticrypt {} mypassword \;. It just gives a blank line and does nothing, when I run this command:
User@Eli-PC MINGW64 /c/Hugo/Sites/leahdemo/public (master)
$ find . -type f -name “*.html” -exec staticrypt {} mypassword ;
find: ‘staticrypt’: No such file or directory
find: ‘staticrypt’: No such file or directory
find: ‘staticrypt’: No such file or directory
find: ‘staticrypt’: No such file or directory
find: ‘staticrypt’: No such file or directory
find: ‘staticrypt’: No such file or directory
find: ‘staticrypt’: No such file or directory
find: ‘staticrypt’: No such file or directory

Probably because staticrypt doesn’t exist in your git bash environment. You’ll need to install Node/NPM, then install staticrypt, then rerun that find command.

You could try: https://gist.github.com/isaacs/579814#file-node-and-npm-in-30-seconds-sh

1 Like