This is a skeleton template for a Quarto website that is password protected and deployed on GitHub Pages.
The website is built and deployed on GitHub Actions.
The GitHub Action, quarto-staticrypt-ghpages.yml
does the following:
- Renders the Quarto project via
quarto render
. - Adds password via
staticrypt
- deploys to Github Pages (given correct configuration as per below)
It assumes any computations are run locally and tracked via the Freeze execution option (i.e. freeze: true
in _quarto.yml
).
Use the "Use this template" button to create a new private GitHub repo with all the files in this repo.
Modify website build and encryption settings in quarto-staticrypt-ghpages.yml
as necessary:
build:
...
env:
PROTECTED_DIR: _site
PASSWORD: password
# PASSWORD: ${{ secrets.YOUR_SECRET }}
PROTECTED_DIR
should match your Quarto project output directory, which by default isoutput_dir: _site
.- To protect a folder of pages rather than your whole website, modify
_site
to_site/folder
.
- To protect a folder of pages rather than your whole website, modify
PASSWORD
sets the encryption password for all pages inPROTECTED_DIR
.- For simplicity, the password is specified by default in plain-text as shown. This means anyone who can access the repository can open this file and read the password. Therefore, make sure your repository remains PRIVATE.
- A more secure option, with slightly more setup is to store the password in a GitHub Secret. Follow these instructions to add secret repository variable that stores your password separately from the github action file. Make sure you comment/uncomment the relevant
PASSWORD:
line, and the name of your secret matches what's in the file (e.g.YOUR_SECRET
)
- Go to
Settings/Pages
and find "Build and deployment" and set "Source" to "GitHub Actions". - A little further down the page, check "Enforce HTTPS"
- Make changes to
.qmd
files. Commit as needed - Re-render your website, with
freeze: true
. This should create/update the rendered content in_site/
, and cache any computational output in_freeze
. - Commit the
_freeze
folder._site
is ignored by default (in.gitignore
) since the GitHub Action renders and deploys the website from source. - Push your changes to GitHub. The push should trigger the action, which will render the website using the frozen computation output, encrypt the specified pages, then deploy the protected website to GitHub pages.
To add encryption to an existing website, simply:
- Copy and paste
quarto-staticrypt-ghpages.yml
into.github/workflows/
your existing repo, creating the folder if it doesn't exist. - configure GitHub Pages to deploy from GitHub Actions as per instructions above.
If you want to run your computations on GitHub actions before rendering the website:
- uncomment the R code steps in the
build
job ofquarto-staticrypt-ghpages.yml
- [optional] change
freeze: true
toauto
orfalse
in_quarto.yml