aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: ad3776834530eb02a5e0a9fb889fd5b707558ae5 (plain)
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
# ssg-blog

This is a modification to the simple static site generator '[ssg](https://romanzolotarev.com/bin/ssg)' by Roman Zolotarev. This is a markdown to HTML static site generator that also creates a minimal blog index page with category headings and posts sorted by date using YAML frontmatter in markdown files.

![example](example/example.webp)

# Install / Usage

See [https://romansolotarev.com/ssg.html](https://romanzolotarev.com/ssg.html) for documentation on ssg

1. Install [lowdown](https://kristaps.bsd.lv/lowdown/) and cpio
2. Copy the `ssg-blog` script somewhere in your path, e.g. `/usr/bin/`
3. `chmod +x /usr/bin/ssg-blog`
4. `ssg-blog src dst 'https://my-website.net'`

ssg-blog checks for subdirectories in the src directory, each of which becomes a category heading (non-recursively). It will generate a sorted list of links to any .md file in those directory (including nested directories). Each .md file needs frontmatter including the title and a YYYY-MM-DD date like this to be included in the index page:

```markdown
---
title: My Blog Post
date: 2024-10-09
publish: false
---
```

If you add `publish: false` to the frontmatter, the post will not show up in the index (it will still be rendered and appear in the sitemap)

## Example

There is an example directory in this repo to show you how to set up the files (src) and what the output looks like (dst). This was the command used to generate the example output:

```
./ssg-blog example/src example/dst 'https://example.org'
```

Note a few things about the output:
1. Markdown files can be nested in subdirectories or not.
2. Files named index.md will get have a link generated without <filename>.html at the end.
3. Files outside subdirectories (e.g. about.md) will be rendered but won't show up on the index.

## Change how categories are sorted

The category headings are sorted alphabetically. If you want to change this, you have to edit the `sort` on this line:

```
find "$src" -mindepth 1 -maxdepth 1 -type d ! -path "*/.*" | sort |
```

# Differences from ssg

The title argument from ssg is unnecessary so I've removed it. `render_html_file` used it to modify the first `<h1>` tag and auto-populate the `<title>` if none is specified, which is functionality I've never needed.

# Alternatives

You might also be interested in the similar fork [fmash16/ssg5](https://github.com/fmash16/ssg5) which generates a more traditional blog with pagination, keywords, and post previews.