flowchart LR
A["Render all Quarto profiles"] --> B["Set up Node.js"]
B --> C["Encrypt instructor HTML with StatiCrypt"]
C --> D["Verify protected and public outputs"]
D --> E["Upload the combined Pages artifact"]
E --> F["Deploy to GitHub Pages"]
Password protection
Static hosting does not normally have a login system. A limited password gate can nevertheless be added to selected Quarto output by encrypting its rendered HTML with StatiCrypt before the site is deployed.
The structure_biology project uses this pattern for its complete instructor site. Student material remains at the site root, scheduled solutions are published below /solution/, and the password-gated instructor version is published below /instructor/.
For the surrounding setup, see Quarto profiles, Release scheduling, and GitHub Pages & Actions.
StatiCrypt is useful for discouraging casual browsing, but it does not add users, permissions, revocation, or server-side authorization to GitHub Pages. Do not use this pattern for confidential, personal, regulated, or assessment-sensitive material that requires real access control.
How the publication flow works
StatiCrypt replaces each selected HTML file with a page containing an encrypted copy of the original document, a password form, and browser-side decryption code. The visitor enters the shared password and the browser decrypts the page. No application server is involved.
Encryption belongs after the final Quarto render and before the Pages artifact is uploaded. If Quarto runs afterward, it overwrites the encrypted files with ordinary HTML.
Create a separate instructor profile
Give the protected profile its own output directory. Restricting it to HTML also avoids presenting PDF or Word downloads that StatiCrypt will not encrypt:
# course_notes/_quarto-instructor.yml
project:
output-dir: _site/instructor
website:
navbar:
right:
- href: ../index.html
text: Go to student version
- href: ../solution/index.html
text: Go to solution version
format-links: false
teaching:
show-solutions: true
default-solution-title: "Solution"The base Quarto configuration should select HTML as its default format. The instructor profile must not add unencrypted output formats. Render all profiles into a combined tree before encryption:
# pixi.toml
[tasks.render-all]
cmd = "quarto render course_notes --profile student,publish && quarto render course_notes --profile solution,publish && quarto render course_notes --profile instructor,publish"
depends-on = ["clean"]
[tasks.clean]
cmd = "rm -rf course_notes/_site"The order matters because the student render creates _site, while the later renders add /solution/ and /instructor/ beneath it.
Keep a stable StatiCrypt salt
Generate the StatiCrypt configuration once from the repository root:
npx --yes staticrypt@3.5.4 --saltThis creates .staticrypt.json with a random salt:
{
"salt": "replace-with-the-generated-32-character-hex-value"
}Commit this file. The salt is not a password and does not need to be secret; it is also embedded in the encrypted output. Keeping it stable allows StatiCrypt’s Remember me option to recognize the same password across different instructor pages and later deployments. Changing or deleting the salt signs remembered users out.
By default, visitors can select Remember me, which stores a salted and hashed password value in browser local storage. Use --remember false in the encryption command if this option should not be offered on shared computers.
Choose where the password is stored
There are two reasonable patterns, depending on what the gate is meant to do.
GitHub Actions repository secret
Use a repository secret when the source is private, or when the password should not be immediately visible in the workflow:
env:
STATICRYPT_PASSWORD: ${{ secrets.STATICRYPT_PASSWORD }}In the repository on GitHub, open Settings → Secrets and variables → Actions, select New repository secret, and create STATICRYPT_PASSWORD. GitHub documents this process in Using secrets in GitHub Actions.
An unavailable secret expands to an empty value, so the workflow should fail before encryption rather than wait for an interactive password prompt. A secret hides the value from the workflow and masks it in ordinary logs, but it does not provide per-user access or prevent recipients from sharing it.
Encrypt during the Pages workflow
Add the following steps to the existing build job after Quarto renders the site and before the Pages artifact is uploaded. The example uses a repository secret; substitute the visible env value above for an intentionally public convenience password.
- name: Set up Node for StatiCrypt
uses: actions/setup-node@v5
with:
node-version: 24
- name: Encrypt instructor site
env:
STATICRYPT_PASSWORD: ${{ secrets.STATICRYPT_PASSWORD }}
run: |
test -n "$STATICRYPT_PASSWORD"
test -f course_notes/_site/instructor/index.html
npx --yes staticrypt@3.5.4 course_notes/_site/instructor/* \
--recursive \
--directory course_notes/_site/instructor \
--config .staticrypt.json \
--short \
--template-title "Course name — instructor"
- name: Verify encrypted output
run: |
grep -q 'staticrypt' course_notes/_site/instructor/index.html
! grep -q 'complete instructor version' \
course_notes/_site/instructor/index.html
! grep -q 'staticrypt' course_notes/_site/index.htmlPinning the Node and StatiCrypt versions makes publication reproducible. The input glob selects the contents of the instructor directory, --recursive processes nested pages, and --directory writes the transformed tree back to the same location. The configuration path points StatiCrypt to the committed salt. --short only suppresses StatiCrypt’s short-password warning; it does not shorten or otherwise alter the password.
The compact verification step confirms that the instructor landing page was transformed, recognizable instructor plaintext is absent, and the public landing page was not encrypted. Replace the example plaintext with a stable phrase that is genuinely present in the project’s instructor page. For a stricter workflow, apply the same checks to a known nested instructor page.
Test the protected output locally
Ordinary Quarto previews should remain unencrypted so maintainers can edit and debug the instructor version quickly. Test the production behavior separately:
pixi run render-all
export STATICRYPT_PASSWORD="temporary-local-test-password"
npx --yes staticrypt@3.5.4 course_notes/_site/instructor/* \
--recursive \
--directory course_notes/_site/instructor \
--config .staticrypt.json \
--short \
--template-title "Course name — instructor"
python -m http.server --directory course_notes/_siteOpen http://localhost:8000/instructor/ and test both an incorrect and the correct password. StatiCrypt 3 uses browser WebCrypto and therefore needs an HTTPS or localhost context; opening the generated HTML directly as a local file is not a representative test. Run the project’s clean task afterward to remove the locally encrypted output before the next render.
Also inspect at least one nested instructor page, the unprotected student and solution sites, and any instructor downloads. Non-HTML files are copied rather than encrypted and can be requested directly if their URLs are known.
Understand the security boundary
StatiCrypt encrypts the selected rendered HTML, but it does not hide:
- Quarto source and repository history in a public repository.
- Images, datasets, PDFs, notebooks, and other non-HTML assets.
- The existence and path of
/instructor/, filenames, or link targets. - Content copied, downloaded, or screenshotted after decryption.
- A password that is committed directly to the workflow.
GitHub Pages is available from private repositories on eligible paid plans, but GitHub states that the published Pages site is still publicly available. See Creating a GitHub Pages site and Securing a Pages site with HTTPS. A private repository plus a secret prevents casual access to the source and password, but visitors still receive the encrypted page from a public URL.
Use an authenticated hosting service with server-side authorization when access must be assigned to named users, audited, or revoked individually.