|
0
|
1 # Format
|
|
|
2
|
|
|
3 This document describes everything a site author writes: the site layout, the
|
|
|
4 configuration, the page sources and the templates. What the generator does
|
|
|
5 with them is in [build.md](build.md).
|
|
|
6
|
|
|
7 ## Site layout
|
|
|
8
|
|
|
9 A site is a directory. The tools are run in it.
|
|
|
10
|
|
|
11 - `config.txt` -- the site configuration.
|
|
|
12 - `src/` -- the page sources, and the images and other files they reference.
|
|
|
13 - `static/` -- files copied to the output as they are, which no page
|
|
|
14 references: a favicon, `robots.txt`.
|
|
|
15 - `tpl/` -- the templates and their assets: stylesheets, images, fonts.
|
|
|
16 - `www/` -- the build directory, configurable. It is output, never input.
|
|
|
17 - `dist/` -- archives written by `make_dist.sh`.
|
|
|
18
|
|
|
19 The output tree mirrors the source tree. `src/notes/first_steps.md` becomes
|
|
|
20 `www/notes/first_steps.html`, and an image next to it is placed next to the
|
|
|
21 output.
|
|
|
22
|
|
|
23 The generator creates only the directories it needs to mirror the source.
|
|
|
24 `index.md` is an ordinary source with no special role. Where directory-style
|
|
|
25 links are wanted, they have to be written out.
|
|
|
26
|
|
|
27 Files from `static/`, from `tpl/` (all except `.html` files) and from `src/`
|
|
|
28 all end up in the build directory. They must not overlap.
|
|
|
29
|
|
|
30 All text files are UTF-8. The output is UTF-8. `.DS_Store` files are not
|
|
|
31 copied.
|
|
|
32
|
|
|
33 ## Site configuration
|
|
|
34
|
|
|
35 `config.txt` uses the same format as the header block of a page, described
|
|
|
36 below. It has no body. A missing `config.txt` is an error, and an unknown key
|
|
|
37 produces a warning.
|
|
|
38
|
|
|
39 Keys:
|
|
|
40
|
|
|
41 - `site_url` -- required. The public address of the site, without a trailing
|
|
|
42 slash. The absolute addresses in the page head are built from it.
|
|
|
43 - `build_dir` -- the output directory. Defaults to `www`.
|
|
|
44 - `image_sizes` -- symbolic image sizes, as a comma-separated list of
|
|
|
45 `<name>:<width in pixels>` pairs.
|
|
|
46 - `extra_header_keys` -- a comma-separated list of page header keys that
|
|
|
47 should not produce a warning.
|
|
|
48 - `index_sections` -- the sections of the root index page that
|
|
|
49 `update_index.py` maintains. A comma-separated list of
|
|
|
50 `<directory>:<heading>` pairs. See [tools.md](tools.md).
|
|
|
51 - `index_recent` -- the number of entries in each of those sections.
|
|
|
52 Defaults to 5.
|
|
|
53
|
|
|
54 All values are available to templates with a `site.` prefix.
|
|
|
55
|
|
|
56 Example:
|
|
|
57
|
|
|
58 site_url: https://www.example.org
|
|
|
59 build_dir: www
|
|
|
60 image_sizes: small:300, half:400, wide:800
|
|
|
61 extra_header_keys: location
|
|
|
62 index_sections: notes:Recent notes
|
|
|
63 index_recent: 3
|
|
|
64
|
|
|
65 A change to `image_sizes` takes effect for existing images only after a clean
|
|
|
66 build.
|
|
|
67
|
|
|
68 ## Pages
|
|
|
69
|
|
|
70 A page is a header block, a blank line and a body. A source that does not
|
|
|
71 start with a header block is an error.
|
|
|
72
|
|
|
73 Further blank lines between the header block and the body are ignored, and so
|
|
|
74 are blank lines at the end of the file. A page with headers and no body
|
|
|
75 produces an empty page and a warning.
|
|
|
76
|
|
|
77 ### Header block
|
|
|
78
|
|
|
79 Lines of `key: value`. The first blank line ends the block.
|
|
|
80
|
|
|
81 A value is literal text to the end of the line. There is no quoting, nesting
|
|
|
82 or list syntax.
|
|
|
83
|
|
|
84 Long values are folded the way mail headers are (RFC 5322). A line that starts
|
|
|
85 with a space or a tab continues the previous value, and the parts are joined
|
|
|
86 with a single space. Leading whitespace is therefore significant in the header
|
|
|
87 block: a continuation line that loses its indentation becomes an invalid
|
|
|
88 header line.
|
|
|
89
|
|
|
90 The order of keys does not matter. A duplicate key produces a warning, and the
|
|
|
91 later value wins.
|
|
|
92
|
|
|
93 Example:
|
|
|
94
|
|
|
95 title: First steps
|
|
|
96 subtitle: Notes from the first week,
|
|
|
97 written down later
|
|
|
98 tags: Notes, Model making
|
|
|
99 created_at: 2026-03-01
|
|
|
100 updated_at: 2026-03-04
|
|
|
101 is_published: 1
|
|
|
102
|
|
|
103 ### Header keys
|
|
|
104
|
|
|
105 `title` is the only required key. A page without a title is an error.
|
|
|
106
|
|
|
107 Keys the generator acts on:
|
|
|
108
|
|
|
109 - `title` -- the page title. The template uses it for the page heading.
|
|
|
110 - `is_published` -- `1` publishes the page. Anything else, or no value,
|
|
|
111 leaves it unpublished. Unpublished pages are only built in draft mode.
|
|
|
112 - `tags` -- a comma-separated list of tags. Empty items are dropped. Each tag
|
|
|
113 links to a tag index page, see [Tag index pages](#tag-index-pages).
|
|
|
114 - `template` -- the file name of a template in `tpl/` to use instead of
|
|
|
115 `page.html`.
|
|
|
116 - `description` -- one or two sentences summarising the page, for search
|
|
|
117 results and link previews. Without it, `subtitle` is used.
|
|
|
118 - `image` -- the link preview image, as a path relative to the source. It is
|
|
|
119 expected to be 1200x630 pixels. See [build.md](build.md).
|
|
|
120 - `crossref` -- the path of a related page, relative to the source, like a
|
|
|
121 link in the body. A `.md` extension is rewritten to `.html`, and the target
|
|
|
122 is checked like a body link. A value with a scheme, such as `https:`,
|
|
|
123 produces a warning and is passed on unchanged.
|
|
|
124 - `created_at` -- an ISO date, `YYYY-MM-DD`, or an ISO date and time such as
|
|
|
125 `2026-03-01T14:30:05+01:00`. Templates get the date as `dd.mm.yyyy`.
|
|
|
126 - `updated_at` -- as `created_at`.
|
|
|
127
|
|
|
128 The generator reads the dates only to format them and to sort tag index
|
|
|
129 pages. A time is accepted and not shown. The date is shown as written,
|
|
|
130 without converting the time zone. A value that is not a valid ISO date
|
|
|
131 produces a warning and is shown as written. The accepted forms are those of
|
|
|
132 Python's `datetime.fromisoformat`, which accepts more of them from Python 3.11
|
|
|
133 on.
|
|
|
134
|
|
|
135 Known keys without defined format, passed to templates as they are:
|
|
|
136
|
|
|
137 - `subtitle` -- a one-line summary.
|
|
|
138 - `timeframe` -- a period, as free text, such as `03.2024 - 06.2025`.
|
|
|
139 - `repository` -- the address of the source repository of a project.
|
|
|
140 - `todo` -- notes for the author.
|
|
|
141
|
|
|
142 Any other key is passed to templates as well, and produces a warning unless
|
|
|
143 it is listed in `extra_header_keys`. The warning only catches typos in keys
|
|
|
144 that are known.
|
|
|
145
|
|
|
146 ### Body
|
|
|
147
|
|
|
148 The body is Markdown, processed by python-markdown with two extensions:
|
|
|
149
|
|
|
150 - `extra` -- abbreviations, attribute lists, definition lists, fenced code,
|
|
|
151 footnotes, Markdown inside HTML, and tables.
|
|
|
152 - `sane_lists`.
|
|
|
153
|
|
|
154 The top-level heading comes from the `title` header through the template. The
|
|
|
155 body usually starts at the second level.
|
|
|
156
|
|
|
157 HTML in the body is passed through. Links and images in it are handled like
|
|
|
158 those written in Markdown, as long as attributes are in double quotes.
|
|
|
159
|
|
|
160 ### Links
|
|
|
161
|
|
|
162 Paths are relative to the source file.
|
|
|
163
|
|
|
164 A link to another page can use the `.md` extension, which is rewritten to
|
|
|
165 `.html`, or the `.html` extension directly. Fragments and query strings are
|
|
|
166 kept. A `.md` link that points nowhere is still rewritten.
|
|
|
167
|
|
|
168 A link to a file that is neither a page nor an image, such as a PDF or an
|
|
|
169 archive, copies that file to the mirrored output path.
|
|
|
170
|
|
|
171 Links with a scheme, such as `https:` or `mailto:`, and protocol-relative
|
|
|
172 links are left alone. All other links are checked, see [build.md](build.md).
|
|
|
173
|
|
|
174 ### Tables
|
|
|
175
|
|
|
176 Standard pipe tables. Outer pipes are optional.
|
|
|
177
|
|
|
178 | Year | Model | Scale |
|
|
|
179 |------|------------|------:|
|
|
|
180 | 2024 | Tug | 1:50 |
|
|
|
181 | 2025 | Lighthouse | 1:87 |
|
|
|
182
|
|
|
183 Alignment markers produce an inline `text-align` style on every cell.
|
|
|
184 Attribute lists cannot be attached to tables, so all tables share one style.
|
|
|
185 Where Markdown cannot express a table, it can be written in HTML.
|
|
|
186
|
|
|
187 ### Footnotes
|
|
|
188
|
|
|
189 A reference is `[^label]` in the text. A definition is `[^label]:` at the
|
|
|
190 start of a line, followed by the text. The label identifies the note and can
|
|
|
191 be any string without whitespace; it is not the printed number. Further
|
|
|
192 paragraphs of a note are indented by four spaces.
|
|
|
193
|
|
|
194 The hull was planked twice.[^planks]
|
|
|
195
|
|
|
196 [^planks]: The first planks were too thick.
|
|
|
197
|
|
|
198 Notes are numbered in the order of their definitions, not of their
|
|
|
199 references. Putting each definition right after the paragraph that refers to
|
|
|
200 it keeps the two orders the same.
|
|
|
201
|
|
|
202 A definition without a reference is still printed and numbered. A reference
|
|
|
203 without a definition stays in the text as written, without a warning.
|
|
|
204
|
|
|
205 The notes are collected at the end of the body in a `div` of class
|
|
|
206 `footnote`. The generator passes them to the template separately, as
|
|
|
207 `footnotes`. The generated ids are `fn:` and `fnref:` followed by the label;
|
|
|
208 they share the id space of the page.
|
|
|
209
|
|
|
210 ### Images
|
|
|
211
|
|
|
212 An image is standard Markdown, with the path relative to the source file:
|
|
|
213
|
|
|
214 
|
|
|
215
|
|
|
216 The output gets `width` and `height` attributes, see [build.md](build.md).
|
|
|
217
|
|
|
218 #### Sizes
|
|
|
219
|
|
|
220 A smaller copy of an image is requested in the file name, by putting a size
|
|
|
221 between the name and the extension:
|
|
|
222
|
|
|
223 
|
|
|
224 
|
|
|
225
|
|
|
226 The size is either a width in pixels or a name from `image_sizes`. The height
|
|
|
227 follows from the aspect ratio. If `hull.800.jpg` exists as a file, it is
|
|
|
228 copied as it is, and no copy is generated.
|
|
|
229
|
|
|
230 PNG and JPEG can be scaled, and WebP where Pillow supports it. Other formats,
|
|
|
231 SVG among them, are only copied.
|
|
|
232
|
|
|
233 #### Layout classes
|
|
|
234
|
|
|
235 An attribute list adds classes, which the stylesheet defines:
|
|
|
236
|
|
|
237 {: .right }
|
|
|
238
|
|
|
239 Class names are not checked. How an image without a class is shown is up to
|
|
|
240 the stylesheet.
|
|
|
241
|
|
|
242 #### Captions
|
|
|
243
|
|
|
244 The title of an image becomes its caption when the image is alone in its
|
|
|
245 paragraph:
|
|
|
246
|
|
|
247 
|
|
|
248
|
|
|
249 The paragraph becomes a `figure` with a `figcaption` below the image. The
|
|
|
250 title attribute is removed, so the caption does not also appear as a tooltip.
|
|
|
251 Classes move from the image to the figure, so a floated image takes its
|
|
|
252 caption along. An image with a title inside running text keeps the title as
|
|
|
253 a tooltip.
|
|
|
254
|
|
|
255 #### Linking to the original
|
|
|
256
|
|
|
257 A thumbnail linked to the original is the nested Markdown construct:
|
|
|
258
|
|
|
259 [](hull.jpg)
|
|
|
260
|
|
|
261 The inner reference generates the smaller copy, the outer link copies the
|
|
|
262 original. An original that is only used for smaller copies is not copied to
|
|
|
263 the output.
|
|
|
264
|
|
|
265 An attribute list attaches to the thumbnail, and a title makes a caption as
|
|
|
266 above:
|
|
|
267
|
|
|
268 [{: .right }](hull.jpg)
|
|
|
269
|
|
|
270 ## Templates
|
|
|
271
|
|
|
272 `tpl/` holds the template set: one or more HTML templates and their assets,
|
|
|
273 which may be in subdirectories. Everything in `tpl/` except `.html` files is
|
|
|
274 copied to the build directory, keeping its relative path.
|
|
|
275
|
|
|
276 - `page.html` is the default page template. The `template` header selects
|
|
|
277 another one.
|
|
|
278 - `tag.html` renders the tag index pages.
|
|
|
279
|
|
|
280 Error pages, such as a 404 page, are ordinary pages.
|
|
|
281
|
|
|
282 ### Markers
|
|
|
283
|
|
|
284 A marker is replaced with a value:
|
|
|
285
|
|
|
286 <h1>{{title}}</h1>
|
|
|
287 <p>{{site.site_url}}</p>
|
|
|
288
|
|
|
289 A marker is `{{`, a key, optionally a `|` and a filter name, and `}}`, with no
|
|
|
290 spaces. Anything else is left as it is, including a stray `{{`. There is no
|
|
|
291 way to escape a well-formed marker.
|
|
|
292
|
|
|
293 Rendered values are not scanned for markers or blocks again.
|
|
|
294
|
|
|
295 A marker for an undefined value renders as an empty string and produces a
|
|
|
296 warning. A marker with an unknown filter, and a marker for a list value, are
|
|
|
297 errors.
|
|
|
298
|
|
|
299 ### Filters
|
|
|
300
|
|
|
301 Values are HTML-escaped by default.
|
|
|
302
|
|
|
303 - `{{key|htmlencode}}` -- HTML-escaped. This is the default, written out.
|
|
|
304 - `{{key|literal}}` -- not escaped. Needed for `body` and `footnotes`.
|
|
|
305 - `{{key|urlencode}}` -- URL-encoded, including `/`.
|
|
|
306
|
|
|
307 ### Blocks
|
|
|
308
|
|
|
309 A condition renders its content only when the condition holds:
|
|
|
310
|
|
|
311 {% if subtitle|isnotempty %}<p class="subtitle">{{subtitle}}</p>{% endif %}
|
|
|
312
|
|
|
313 Conditions:
|
|
|
314
|
|
|
315 - `isempty` -- the value is undefined, an empty string or an empty list.
|
|
|
316 - `isnotempty` -- the opposite.
|
|
|
317
|
|
|
318 An unknown condition is an error. A condition on an undefined value does not
|
|
|
319 produce a warning.
|
|
|
320
|
|
|
321 A loop renders its content once for every item in a list:
|
|
|
322
|
|
|
323 {% loop tags %}<li><a href="{{url}}">{{name}}</a></li>{% endloop %}
|
|
|
324
|
|
|
325 The list has to be a list of dictionaries. Inside the loop only the keys of
|
|
|
326 the current item are available; page values such as `relRoot` are not. A loop
|
|
|
327 over an undefined value renders nothing and produces a warning. A loop over
|
|
|
328 anything other than a list of dictionaries is an error, and so is a condition
|
|
|
329 on a loop.
|
|
|
330
|
|
|
331 A block cannot contain another block of its own kind, at any depth: the
|
|
|
332 inner end tag would close the outer block. A condition inside a loop, or a
|
|
|
333 loop inside a condition, works. A block tag that is not part of a complete
|
|
|
334 block is an error.
|
|
|
335
|
|
|
336 ### Page values
|
|
|
337
|
|
|
338 - `site.<key>` -- every key of the site configuration.
|
|
|
339 - Every header of the page, under its own name. Headers the page does not set
|
|
|
340 are undefined.
|
|
|
341 - `body` -- the HTML of the body, without the footnotes. Use with `literal`.
|
|
|
342 - `footnotes` -- the footnotes `div`, or empty. Use with `literal`. A template
|
|
|
343 without it drops the footnotes.
|
|
|
344 - `tags` -- the tags of the page, as a list of items with `name` and `url`.
|
|
|
345 The address is relative to the page. Empty for a page without tags.
|
|
|
346 - `crossrefUrl` -- the `crossref` header as an address relative to the page,
|
|
|
347 with `.md` rewritten to `.html`. Empty without the header.
|
|
|
348 - `relRoot` -- the relative path from the page to the site root, ending in a
|
|
|
349 slash. `./` at the top level. For links to assets and other pages.
|
|
|
350 - `absRoot` -- `/`. For error pages, which the server delivers at other
|
|
|
351 addresses than their own.
|
|
|
352 - `pageUrl` -- the absolute address of the page. An `index.html` is
|
|
|
353 addressed by its directory, ending in a slash.
|
|
|
354 - `metaDescription` -- the `description` header, or `subtitle` without one,
|
|
|
355 or empty.
|
|
|
356 - `createdDate`, `updatedDate` -- the dates of `created_at` and `updated_at`
|
|
|
357 as `dd.mm.yyyy`. Empty without the header. `updatedDate` is also empty when
|
|
|
358 it is the same date as `createdDate`.
|
|
|
359 - `ogImage`, `ogImageWidth`, `ogImageHeight`, `ogImageAlt` -- the link
|
|
|
360 preview image: its absolute address, its size in pixels, and the alt text of
|
|
|
361 the image it was cut from. Undefined when there is no preview image; the
|
|
|
362 template then names its own default or none. See [build.md](build.md).
|
|
|
363
|
|
|
364 ### Tag index pages
|
|
|
365
|
|
|
366 Tag index pages have no source. They are written to the build root as
|
|
|
367 `tag_<name>.html`. The name is the tag in lower case, with everything other
|
|
|
368 than the letters a to z and digits removed: "Model making" becomes
|
|
|
369 `tag_modelmaking.html`. Tags that differ only in case, spaces or punctuation
|
|
|
370 share one page. A source with the same name as a tag index page collides
|
|
|
371 with it.
|
|
|
372
|
|
|
373 Values for `tag.html`:
|
|
|
374
|
|
|
375 - `site.<key>` -- as for pages.
|
|
|
376 - `tag` -- the tag. Where several spellings share a page, the first one found.
|
|
|
377 - `relRoot` -- always `./`. `absRoot` -- `/`.
|
|
|
378 - `pageUrl` -- the absolute address of the tag index page.
|
|
|
379 - `pages` -- the pages with this tag, newest first by `created_at`, then by
|
|
|
380 title. Pages without `created_at` come last. Each item has the headers of
|
|
|
381 its page except `tags`, plus:
|
|
|
382 - `url` -- the address of the page, relative to the build root. It
|
|
|
383 replaces a header of the same name.
|
|
|
384 - `descOrSubtitle` -- the `description` header, or `subtitle` without
|
|
|
385 one, or empty.
|
|
|
386
|
|
|
387 A header that a page does not set is undefined in its item, and a marker for
|
|
|
388 it produces a warning. Optional headers belong in a condition.
|
|
|
389
|
|
|
390 ### Stylesheets
|
|
|
391
|
|
|
392 Every local image in the output has `width` and `height` attributes. A
|
|
|
393 stylesheet that limits the width of images has to set `height: auto`.
|