source: code/trunk/README.md@ 44

Last change on this file since 44 was 39, checked in by zaitsev.serge, 10 years ago

updated README

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