A simple static site generator using sh as a templating language


We provide binaries for Linux and OpenBSD. It can also run on Windows via the Windows Subsystem for Linux for other UNIX like operating systems, you can build from sources.

Install mkws

On a Linux machine, just download the archive from or in the terminal, assuming curl is installed, type:

curl | tar -xzvf - 

Generate the Static Site

Rename the directory you unarchived earlier to your site's name:

mv && cd

Create your first template named index.upphtml, this is required by mkws:

cat <<EOF > index.upphtml
echo hello, world

Run mkws:


You just generated your first static site with mkws. You will now have an index.html file in your . root directory containing the following code:

<!doctype html>
<html lang=en>

<title>My website</title>

<meta charset=UTF-8>
<meta name=viewport content='width=device-width, initial-scale=1'>


hello, world

To create new pages, just add new *.upphtml files in the . root directory, mkws automatically scans for them. You can create an aboutus.upphtml or a contact.upphtml file for example to generate an aboutus.html or a contact.html page.

For further customizations you can always modify your ./bin/mkws or ./share/l.upphtml files, in fact, it's recommended.


mkws uses *.upphtml files as templates which are processed via pp, a preprocessor that allows embedding sh code in files of any type by nesting it inside the #!\n token, where \n is a new line.

As an example, for the following code:

while test $i -le 10
if test $((i % 2)) -eq 0
	<li class=even>$i</li>
	<li class=odd>$i</li>
i=$((i + 1))
pp outputs:
	<li class=odd>1</li>
	<li class=even>2</li>
	<li class=odd>3</li>
	<li class=even>4</li>
	<li class=odd>5</li>
	<li class=even>6</li>
	<li class=odd>7</li>
	<li class=even>8</li>
	<li class=odd>9</li>
	<li class=even>10</li>

This means you can script your templates in any way you prefer using preferably, standard UNIX tools for portability reasons.


Because pp uses sh internally, double quotes (") must be escaped in templates, so to get an actual double quote (") you have to write \".

This isn't a problem for HTML because quoting attribute values is optional and double quotes and single quotes are interchangeable. We recommend not quoting attribute values and using single quotes (') in special cases.

So instead of:

<!doctype html>
<html lang="en">

<title>My website</title>

<meta charset="UTF-8">
you would write:
<!doctype html>
<html lang=en>

<title>My website</title>

<meta charset=UTF-8>

How to customize mkws

Customization is done by editing the template (*.upp*) files in your mkws project, the ones you create yourself in the . directory, the themes files in ./share, ./share/l.upphtml, ./share/s.uppcss and ./share/sitemap.uppxml, and the main generating script in ./bin/mkws. You can also install additional utilities in the ./bin directory to enable new functionality.

Below are a few solutions to common problems.

How to output in a separate directory

A common practice static site generators use is to output the generated files in a separate directory, like out or public. mkws is designed to output its files in the current directory, along with the sources, it does however have an option to specify to source path. So to output in a different directory than the sources one, you could do in your . directory:

mkdir htdocs
cd htdocs
../bin/mkws ../

However, we do recommend distributing the .upp* files so other can people can read and learn from your code, and preferably link to them.

How to preview your website

Some static site generators usually come bundled with an HTTP server, so you can run something like:

ssg -p 8080
and preview your site. mkws doesn't include a server by default, you can use any server you prefer, however we do provide a small server written in Go: https.go. You can either compile the source or download a statically linked binary for Linux: https. To install, in your web site's directory, on a Linux machine, in a terminal, do:
curl -so bin/https
chmod +x bin/https

If you prefer compiling the sources:

curl -so https.go
go build -o bin/https https.go

Open in your browser to preview your website.

The server runs on port 9000 by default and uses the current directory as its root directory. It outputs a log to stdout in Common Log Format .

How to live reload

A nice feature when developing a web site, is to have the static site generator run whenever a source files has changed and reload the current page in the browser.

Assuming you installed our web server following the previous instructions, the recommended way to do this with mkws is to either install or compile entr, get live.js, in your web site's directory, do:

curl -so l.js

Edit share/l.upphtml by adding:

if test "$DEV" -eq 1
<script src=/l.js></script>

above the closing </body> tag.


cat <<EOF > bin/d
	#!/bin/sh -e

	export DEV=${DEV:-1}

	./bin/https &

	echo ./bin/mkws
	find . -type f -name '*.upp*'
	) | entr sh -c 'bin/mkws'
chmod +x bin/d
Run the development script:
And open in your browser.

How to add a navigation menu

In order to add a navigation menu to your website, all you have to do is edit the ./share/l.upphtml file and add your navigation code there. Open up ./share/l.upphtml in your favorite text editor and add the following lines right below the body tag:

			<li><a href=/>Home</a></li>
			<li><a href=docs.html>Docs</a></li>
			<li><a href=src.html>Sources</a></li>
Edit to match your website, then regenerate your site using the mkws command:

How to add custom titles (or meta tags) for each page

As you can see, using ./share/l.upphtml to generate all our pages, means we have only one title tag for each page, hence all of our generated pages will have the same title. If we would prefer specific titles for each page, we would have to edit ./share/l.upphtml like in the following example:

case "$1" in
<title>My Website</title>
<meta name=description content='Latest news about my website'>
<meta name=description content='Documentation for my website'>
<meta name=description content='Sources for my website'>
Edit to match your website, then regenerate your site using the mkws command:

How to render Markdown

Rendering Markdown is not at hard at all. Our favorite CLI tool for rendering Markdown is smu. You'll have to download it and install it on your system either via source or your operating systems's package manager. In order to use it, just add:

	smu <file>
to any of your *.upphtml files or create a new *.upphtml files containing just the above code. Other Markdown renderers include cmark, lowdown discount.

Future versions of mkws may allow rendering Markdown directly from source, without creating an extra *.upphtml file.

File Hierarchy

A typical mkws project has the following file structure:

	|-- bin
	|   |-- lmt
	|   |-- mkws
	|   `-- pp
	`-- share
	    |-- l.upphtml
	    |-- man
	    |   `-- man1
	    |       |-- lmt.1
	    |       |-- mkws.1
	    |       `-- pp.1
	    |-- s.uppcss
	    `-- sitemap.uppxml



The package contains a Linux amd64 pp 1.0.11 statically compiled binary, a mkws 5.0.0 sh script, a base 4.0.0 theme and lmt from lts 0.1.4. mkws-openbsd@5.0.0.tgz is the OpenBSD binary version.



Full Changelog

Previous versions



The main mkws sh script

Previous versions

Base files for a theme, you can use it to make your own theme
pp, the sh preprocessor
File time data

Built with mkws


What people are saying


How to contribute

Make a web site 😉 and send a link to!

You can also sponsor me: