Static site generation
Pre-render all pages for deployment to static hosting.
Static site generation
The build-static.sh script renders every .md and .url source file
into static HTML for deployment to any web server or static hosting
service.
Invocation
bash tools/build-static.sh <scheme://hostname> [output-dir]
Arguments
scheme://hostname(required) - base URL of the site. SetsSERVER_NAMEandREQUEST_SCHEMEfor correct URL interpolation.output-dir(optional) - directory to write the generated site. Defaults to in-place build inpublic_html.
Example
Build in-place:
bash tools/build-static.sh https://example.com
Build to a separate output directory:
bash tools/build-static.sh https://example.com ./dist
Build and deploy:
bash tools/build-static.sh https://example.com ./dist
rsync -av --delete ./dist/ user@host:/var/www/html/
Behaviour
- Locates the docroot (
public_html/or current directory) - If an output directory is given, copies source files there
(excluding
.htmlcache files) - Clears all existing
.htmlfiles (except underlazysite/) - Processes every
.mdand.urlfile through the processor - Reports OK/FAIL for each page
- If an output directory was used, removes
.mdand.urlsource files from the output
Notes
- The processor must be at
cgi-bin/lazysite-processor.plrelative to the docroot (checked at both../cgi-bin/and./cgi-bin/) - Remote
.urlpages are fetched during the build SERVER_PORTis set to 443 andHTTPSto "on" during the build- The script exits with status 1 if any pages fail to render
- Cache management - how caching works during normal operation