aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: cc099c89b8d8c45f30c3534a4bdf8d80d12a9b28 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# snkt

Snkt is a static web site generator for with a focus on simplicity and efficiency.

## Simplicity

snkt only does a few things, but strives to do them well, in a coherent manner.

## Efficiency

snkt generates my [personal web site of ~2000 articles in under a second](https://trenchant.org/daily/2017/1/31/). Additional work may be done to increase efficiency, but it should be fast enough to regularly regenerate your site without concern in near real-time if needed.

## Status

Currently in development. It powers [trenchant.org](https://trenchant.org) but is "alpha" quality and parts may change.

## What

Takes a bunch of plain text files, processes them via templates, and generates HTML. Pretty much like you'd expect of a static site generator.

## Why

Every 5-10 years I throw out the software for my site and rewrite it. 

This time it's in Go. Maybe you'll find it useful. 

I found it fun to get myself thinking in Go. Also, it's 10x faster than the old version in Python.


## Getting snkt

Install Go https://golang.org and set up $GOPATH if you haven't already

    $ mkdir $HOME/go
    $ export GOPATH=$HOME/go
    
Add $GOPATH/bin to your PATH

    $ export PATH=$PATH:$HOME/go/bin

Install dependencies

    $ go get gopkg.in/yaml.v2
	$ go get github.com/russross/blackfriday

Install snkt

    $ go get adammathes.com/snkt
    
This should should download and build `snkt` and place it in $HOME/go/bin

## Setting up a site

Use the "-init" option to create the skeleton for a new site -

    $ snkt -init blogadu
    
This will create:

   * `txt` -- a directory for plain text input
   * `html` -- a directory for HTML output
   * `tmpl` -- a directory for templates with basic templates:
     * `base` -- basic HTML structure for all pages
     * `post` -- single post page
     * `index` -- a home page showing the most recent entires
     * `archive` -- a list of all post
     * `rss` -- tempalte for an RSS 2.0 archive 
   * `config.yml` -- configuration file


## Writing Your First Post

A one line plaint text file is a valid post.

    user@host:~/blogadu$ echo "hello world" >> txt/hi

Build the site with --

    $ snkt -b

Output should now be in the `html` directory -- including an index.html, archive.html, rss.xml, and `hi/index.html`

You can run a preview server with

    $ snkt -p
    
Loading http://localhost:8000 in a web browser should now show you the site.

Snkt will use `config.yml` by default if it's in the working directory. Otherwise you can specify it with an explicit `-c /path/config.yml` flag.

## Command Line Usage

```
Usage of snkt:
  -b	build the site
  -c string
    	configuration file (default "config.yml")
  -h	help
  -init directory
    	initialize new site at directory
  -p	start local HTTP server for preview
  -v	print version number
  -verbose
    	log more actions while building
```

## Configuration File

The configuration is in [YAML](http://yaml.org)

For most purposes, it should just be a listing of attribute : value

Configuration options --

   * `input_dir` -- absolute path of directory for text input files
   * `output_dir` -- absolute path of directory for html output files
   * `tmpl_dir` -- absolute path of directory for template files
   * `site_title` -- string for the site's title (used in templates)
   * `site_url` -- absolute URL for the site (used in templates)
   * `filters` -- tools of the dark arts I haven't documented yet
   * `permalink_fmt` -- format string for permalinks (see #permalinks)
   * `post_file_fmt` -- format string for post filenames (see #permalinks)
   * `show_future` -- include posts with dates in the future or hide them
   * `preview_server` -- host:port to spawn the preview server (default: localhost:8000)
   * `preview_dir` -- root directory of preview server (default: same as output_dir)

## Posts

Post inputs are stored as plain text files. (I have only tested UTF-8 and ASCII.)

Posts have an optional metadata preamble, and a markdown formatted body. The preamble is just a series of name value pairings separated by a colon (:) character.

Minimal complete and valid post --

    this is a totally valid post

Post with a preamble --

    title: also a valid post
    date: 2017-02-08
    valid: totes

    This post will have an explicitly set title (ooh! fancy!) instead of inferred from the filename. 

    It will also have an explicitly set date instead of inferring it from the file creation/modification time.

    `totes` will be stored in the post's `meta` map under `valid.` You don't have to worry about that right now, I'll explain later. Maybe.

## Templates

## Advanced Features

### Permalink and filename formatter

### Filters

### Auto-rebuild/deployment