Site

build crates.io

Site is a fast, simple, and opinioned static site generator, written in Rust. Highlights include:

Install

shell cargo install site

Usages

No documentations yet.

Meanwhile, as a living document, use hayatoito/hayatoito.github.io as your starter boilerplate. https://hayatoito.github.io/ is built from that repository.

Folder structure

text root_dir/ - src/ - (Put your markdown files here) - template/ - (Put your template files here)

Markdown format

Site uses markdown.

```markdown

Article title

Section

Hello Article!

Nothing special except for:

Metadata

TODO: Explain

| Name | Description | Default value | | ------------- | ----------------------------------------- | ----------------------------------------- | | page | | false | | date | | (date is mandatory unless page: true) | | update_date | | NA | | author | | NA | | slug | The page's URL | Calculated by a relative PATH to src | | toc | Whether to generate Table of Contents | false | | toc_level | | NA (arbitrary depth) | | draft | Skip this markdown | false | | template | Template file to use in template folder | article or page |

Pages

If a markdown's metadata contains page: true, Site consider that the markdown represents a page, instead of an article.

```markdown

Page title

Section

Hello Page!

The differences between article and page are:

Template variables

TODO: Explain

| Name | page | article | Description | | ------------------ | ---- | ------- | ---------------------------------------------------------- | | entry | x | x | Represents an article or a page (its metadata and content) | | site | x | x | Site configuration given by --config parameter | | articles | x | | The list of the articles | | articles_by_year | x | | The list of { year, articles} |

entry

In addition to its metadata, entry contains the following fields:

| Name | Description | | ---------------- | ------------------------------ | | entry.title | Title | | entry.content | Generated HTML | | entry.toc_html | Generated TOC (if toc: true) |

Build

CLI

shell site build --root-dir . --config=config.toml --out-dir out

root-dir should contain src and template folders.

See Make.zsh for the example CLI usages for various tasks.

GitHub Action

You can also use GitHub Action to build and deploy automatically if you are using GitHub Pages. See build.yml as an example.