Build environment (Node, Playwright, renderer)
This page explains how to run the official Sercrod renderer used for
this site. It uses Node, Playwright (Chromium), and two small scripts:
server.js and builder.js.
After the setup, you can:
- start a local build server,
- build one page at a time from the command line,
- and hook builds into your editor on save.
Prerequisites
You will need:
- Node.js and npm (recent LTS or later),
- network access to download Playwright and Chromium,
- a directory where your Sercrod sources live.
The examples below assume:
/home/sercrod.com/src? Sercrod sources, templates, and scripts,/home/sercrod.com/public_html? generated static HTML.
You can adapt the paths to your own environment, as long as
server.js and builder.js use the same layout.
Directory layout
A typical layout for the renderer is:
/home/sercrod.com/
public_html/ # output: generated static HTML
src/ # sources and tools
template.html # layout template for all pages
home.html # partial: home page
docs/ # partials for documentation
index.html
guide/
first-page.html
data-and-events.html
...
reference/
ssg-ssr.html
config.html
build-environment.html
server.js # build server (Node + Playwright)
builder.js # CLI front-end that calls the server
The renderer treats template.html as the layout and
each partial (for example, home.html) as the source
of per-page content and metadata.
Install Node dependencies
In the src directory, initialize a Node project and
install the required packages:
cd /home/sercrod.com/src
npm init -y
npm install playwright js-beautify
This creates package.json and adds Playwright and
js-beautify as dependencies.
Then install the Chromium binary for Playwright:
npx playwright install chromium
If you want to use other browsers, you can install them as well, but the official renderer uses Chromium.
server.js ? local build server
The build server is a Node script (for example server.js)
that:
- listens on a local port (for example
http://0.0.0.0:1414/), - maps a URL such as
/home.htmlto a partial file undersrc/, - uses Playwright + Chromium to open
template.html, - injects
partial.dataand the partial HTML, - runs Sercrod to expand directives,
- and writes the final HTML to
public_html/.
The full server.js implementation lives in the
repository. Once placed under /home/sercrod.com/src,
you can start it with:
cd /home/sercrod.com/src
node server.js
If it starts correctly, you should see a message such as:
server.js listening on http://0.0.0.0:1414/
builder.js ? CLI front-end
The builder is another Node script (for example builder.js)
that sends a request to the local server and waits for the build
result. It:
- accepts a URL or path as an argument (for example
/home.html), - normalizes it to a URL path (for example
/home.htmlor/docs/guide/first-page.html), - sends an HTTP GET request to
http://127.0.0.1:1414/..., - and prints the status returned by
server.js.
Once server.js is running, you can build a page by:
cd /home/sercrod.com/src
node builder.js /home.html
If the build succeeds, the command exits with status 0
and writes an HTML file under public_html using the
same relative path. For example:
/home.html→/home/sercrod.com/public_html/home.html/docs/guide/first-page.html→/home/sercrod.com/public_html/docs/guide/first-page.html
Building from the editor
Because builder.js is a simple CLI tool, you can call
it from your editor or other automation whenever you save a file.
The typical pattern is:
- Detect which HTML partial you just saved.
- Convert its filesystem path to the corresponding URL path.
- Run
node builder.js <that-url-path>.
This keeps the build logic in one place (the server and builder) while letting you trigger SSG from any tool that can run a shell command.
Summary
template.htmldefines the shared layout.- Each partial (
*.htmlundersrc/) defines a page. server.jsruns Playwright + Sercrod and writes static HTML.builder.jsis a small wrapper that asks the server to build one page.
With this setup, you can treat Sercrod as a small engine inside a static site generator, without adding a large framework or replacing your existing HTML.