source: code/trunk/README.md@ 49

Last change on this file since 49 was 48, checked in by prologic, 4 years ago

Forked project

File size: 3.0 KB
Line 
1# zs
2
3zs is an extremely minimal static site generator written in Go.
4
5It's inspired by `zas` generator, but is even more minimal.
6
7The name stands for 'zen static' as well as it's my initials.
8
9## Features
10
11* Zero configuration (no configuration file needed)
12* Cross-platform
13* Highly extensible
14* Works well for blogs and generic static websites (landing pages etc)
15* Easy to learn
16* Fast
17
18## Installation
19
20Download the binaries from Github or build it manually:
21
22 $ go get git.mills.io/prologic/zs
23
24## Ideology
25
26Keep your texts in markdown, or HTML format right in the main directory
27of your blog/site.
28
29Keep all service files (extensions, layout pages, deployment scripts etc)
30in the `.zs` subdirectory.
31
32Define variables in the header of the content files using [YAML]:
33
34 title: My web site
35 keywords: best website, hello, world
36 ---
37
38 Markdown text goes after a header *separator*
39
40Use placeholders for variables and plugins in your markdown or html
41files, e.g. `{{ title }}` or `{{ command arg1 arg2 }}.
42
43Write extensions in any language you like and put them into the `.zs`
44subdiretory.
45
46Everything the extensions prints to stdout becomes the value of the
47placeholder.
48
49Every variable from the content header will be passed via environment variables like `title` becomes `$ZS_TITLE` and so on. There are some special variables:
50
51* `$ZS` - a path to the `zs` executable
52* `$ZS_OUTDIR` - a path to the directory with generated files
53* `$ZS_FILE` - a path to the currently processed markdown file
54* `$ZS_URL` - a URL for the currently generated page
55
56## Example of RSS generation
57
58Extensions can be written in any language you know (Bash, Python, Lua, JavaScript, Go, even Assembler). Here's an example of how to scan all markdown blog posts and create RSS items:
59
60``` bash
61for f in ./blog/*.md ; do
62 d=$($ZS var $f date)
63 if [ ! -z $d ] ; then
64 timestamp=`date --date "$d" +%s`
65 url=`$ZS var $f url`
66 title=`$ZS var $f title | tr A-Z a-z`
67 descr=`$ZS var $f description`
68 echo $timestamp \
69 "<item>" \
70 "<title>$title</title>" \
71 "<link>http://zserge.com/$url</link>" \
72 "<description>$descr</description>" \
73 "<pubDate>$(date --date @$timestamp -R)</pubDate>" \
74 "<guid>http://zserge.com/$url</guid>" \
75 "</item>"
76 fi
77done | sort -r -n | cut -d' ' -f2-
78```
79
80## Hooks
81
82There are two special plugin names that are executed every time the build
83happens - `prehook` and `posthook`. You can define some global actions here like
84content generation, or additional commands, like LESS to CSS conversion:
85
86 # .zs/post
87
88 #!/bin/sh
89 lessc < $ZS_OUTDIR/styles.less > $ZS_OUTDIR/styles.css
90 rm -f $ZS_OUTDIR/styles.css
91
92## Command line usage
93
94`zs build` re-builds your site.
95
96`zs build <file>` re-builds one file and prints resulting content to stdout.
97
98`zs watch` rebuilds your site every time you modify any file.
99
100`zs var <filename> [var1 var2...]` prints a list of variables defined in the
101header of a given markdown file, or the values of certain variables (even if
102it's an empty string).
103
104## License
105
106The software is distributed under the MIT license.
Note: See TracBrowser for help on using the repository browser.