Sūshì is a simple but customizable static site generator / blog generator written in Rust

Overview

sūshì

Sūshì is a simple but customizable static site generator / blog generator written in Rust.

Installation

Install with Cargo (Recommended)

cargo install sushi-gen

ssushi will be installed in .cargo/bin. Now check the installation.

ssushi --help

Compile from Source Manually

Clone this repository and cd into it:

git clone https://github.com/fpg2012/sushi
cd sushi

And build it with Cargo:

cargo build --release

The binary executable ssushi will be placed in target/release

Quick Start

For Linux users:

  1. Install sushi

  2. Get a starter (or so called "theme"), for example

    git clone https://github.com/fpg2012/sushi-theme-letter
    

    Copy the starter into config directory and rename it to default. On Linux, it is $XDG_CONFIG_DIR/sushi-gen or $HOME/.config/sushi-gen. (Refer to ProjectDirs in directories). Don't forget to install all dependencies of the starter.

  3. Initialize your site

    ssushi init [your_site_name]
    
  4. Build the site

    ssushi build
    
  5. Now the site is generated into _gen folder. You can install sfz to serve the site.

    cargo install sfz
    sfz -r _gen
    

How does sūshì work?

Site Structure

A Sūshì site might look like this:

sushi-theme-letter
├── assets
├── _converters (*)
│   ├── convert.sh
│   └── pandoc-katex
├── _gen
├── _includes (*)
│   ├── footer.liquid
│   ├── header.liquid
│   └── katexcss.liquid
├── index.md
├── notes
├── posts
│   ├── 2021-04-04-some-post-with-assets
│   │   ├── pic1.png
│   │   ├── pic2.png
│   │   └── index.md
│   └── 2022-03-18-some-post.md
├── _site.yml (*)
└── _templates (*)
    ├── page.liquid
    └── post.liquid

Actually only _converters, _includes, _templates and _site.yml are necessary and should NOT be renamed. Once sushi starts, it reads these files and folders first and load them into memory.

Templates (written in liquid template language) and partials (in liquid too) should be stored in _templates and _includes respectively. Site configurations are written in _site.yml. _converters stores executables for converting page files into HTML pages (e.g. markdown parsers).

Note that sūshì does not parse markdown (or any other format) directly, what it does is simply compiling templates you provide and insert the converted page contents into them. You can write your parser, or write a simple script to execute some parser (e.g. pandoc).

After reading these important configurations, sushi convert all pages found by execute the converters. Folders and file start with . or _ will be ignored. All file that are not recognized as "page files" will be copied directly to the corresponding locations.

Generated site is put in _gen folder.

Site Configuration

_site.yml might look like this:

site_name: "my site"
author: "my name"
url: "https://example.com"
# ...
convert_ext: ["html", "md"]
converter_choice:
  - md: "converter.sh"
taxonomies: ["category", "tag"]
configuration value type function
convert_ext array of string Valid extensions of page file. File with extension listed here is considered as page file.
converter_choice array of map Specific which converter to be used. If not set, all pages will be inserted to templates directly.
taxonomies array of map List of taxonomies
url string Base url of the site. If not set, "/" will be used.

Page Front Matter

Front matter contains the configuration of the page.

---
layout: post
title: "Test of Sushi"
date: "2022-03-12"
tag: ["a", "b", "c"]
category: ["dev"]
---
name usage
layout (required) name of the template
date (required) date, like "2022-03-12"
[taxonomy name] list of taxonomy value
paginate the list used for pagination
paginate_batches number of items in a batch
next id of next page
last id of last page

Write Templates

Liquid

Sushi uses the rust implementation of liquid template language. For syntax of liquid, please refer to the documentation of liquid languague and liquid crate.

Global Objects

Sushi offers some global liquid variables.

name usage
site All configurations in _site.yml are inserted into the object. For example, site.site_name is the site_name set in _site.yml. site.time is the datetime of generating the site.
page Front matter of current page.
content Content of current page. string.
sitetree Site tree
taxo Taxonomy list
id_to_page Map page_id to page object
all_pages List of all page_id
paginator Paginator

Besides the key-value pair defined by user in _config.yml and front matter, site and page object contains some generated information.

name usage
site.time Datetime of generating the site
page.url URL of page
page.path Path of original page file
page.next ID of next page
page.last ID of last page

sitetree object

name usage
sitetree._home Object of root directory
sitetree.[folder] Object of [folder] directory
sitetree.[folder1].[folder2] Object of folder1/folder2
sitetree.[folder]._list page_ids of pages in the folder. Index page_id of child folder will be listed here too. For example, all pages in "post" folder will be list in sitetree.post._list. Similarly, all pages in "posts/notes" will be listed in sitetree.posts.notes._list

taxo object

name usage
taxo._key List of taxnonomies.
taxo.[taxonomy] Object of taxonomy, for exmaple taxo.tag, taxo.category
taxo.[taxonomy].[taxonomy_value] List of page_id of pages with the taxonomy value. For example, all page_id of pages with tag "rust" will be listed in taxo.tag.rust
taxo.[taxonomy].[taxonomy_value]._key List of valid taxonomy value

Template Front Matter

name usage
layout template name of parent template

Template inheritance is supported, which is similar to that of Jekyll. If template post inherites template page, the render result of post will be the content inserted to page.

result1 result1 =="page"=> result2 // the final result in this example">
page_content =="post"=> result1
result1 =="page"=> result2 // the final result in this example

Add Partials

If a snippet of code is used by multiple templates, it is recommended to split them to a partial file. All partial file should be put in _includes folder.

For example, if header.liquid is put in _includes folder, you can use {{ include header }} in your template to include it.

Paginator

Paginator is used to split a page into mutiple pages (for example, when showing a super long list of page titles in home page).

Usage of paginator is a little bit complex.

First, paginator of sushi is based on "list", it splits the list into multiple "batches". So you should put the list you want to split into page front matter.

---
#...
paginate: sitetree.posts._list # the list you want to split
paginate_batches: 4 # the number of item in a batch
---

And then, use the paginator object in your template. For example:

{{ id_to_page[page_id].title }} {% endfor %} {% if paginator.batch_num > 1 %} {% if paginator.next_batch_num %} {{ paginator.next_batch_num }} {% endif %} {% if pageinator.last_batch_num %} {{ paginator.last_batch_num }} {% endif %} {% endif %}">
{% for page_id in paginator.current_batch %}
  <li><a href="{{ id_to_page[page_id].url }}">{{ id_to_page[page_id].title }}a>li>
{% endfor %}
{% if paginator.batch_num > 1 %} 
{% if paginator.next_batch_num %}
  <a href="{{ paginator.batch_urls[paginator.next_batch_num] }}">{{ paginator.next_batch_num }}a>
{% endif %}
{% if pageinator.last_batch_num %}
  <a href="{{ paginator.batch_urls[paginator.last_batch_num] }}">{{ paginator.last_batch_num }}a>
{% endif %}
{% endif %}

After pagination, page test.md might be split into

test.html
test
├─1.html
├─2.html
├─ ....
└─10.html
name usage
paginator.current_batch current batch
paginator.current_batch_num number id of current batch
paginator.next_batch_num number id of next batch
paginator.last_batch_num number id of  last batch
paginator.batch_urls list of batch urls
paginator.items the list before splitting
paginator.batch_num number of batches

Write Converters

Writing converters is quite simple. A converter is a executable reads input from stdin and writes output to stdout. That's all.

For example, you can write a shell script to execute pandoc

#!/bin/bash
pandoc -f [filter] --katex

Site Initialization and Starters

When you execute ssushi init [sitename], sushi will search for a starter named "default" in project config folder and current working directory, and then simply copy it to ./[sitename].

You can use --theme [starter_name/starter_path] option to use other starters.

Note that there is no default starter after installation with Cargo, you should create one manually.

You might also like...
Zine - a simple and opinionated tool to build your own magazine.

zine Zine - a simple and opinionated tool to build your own magazine. Mobile-first. Intuitive and elegant magazine design. Best reading experiences. T

serve a static site, single page application or just a static file with Rust
serve a static site, single page application or just a static file with Rust

cargo-server tl;dr: Does the same as "python -m http.server" or "npx serve" but for Rust ecosystem. cargo-server helps you serve a static site, single

Serve a static site, single page application or just a static file with Rust
Serve a static site, single page application or just a static file with Rust

cargo-server tl;dr: Does the same as "python -m http.server" or "npx serve" but for Rust ecosystem. cargo-server helps you serve a static site, single

Hot reload static web server for deploying mutiple static web site with version control.

SPA-SERVER It is to provide a static web http server with cache and hot reload. 中文 README Feature Built with Hyper and Warp, fast and small! SSL with

Kurzlink is a simple static site generator built in rust

kurzlink What is kurzlink? Kurzlink is a simple static site generator built in rust.

An ultra simple static site generator designed to appeal to technical as well as non technical users.

Hulk is an ultra simple static site generator designed to appeal to both technical and non technical users.

Static site generator written in Rust
Static site generator written in Rust

Sedum is a static site generator written in Rust. It can be used locally or with a service like Netlify to generate websites on the fly. Usage Local P

A hypersonic static-site generator written in Rust. 🚀 💊 🔥
A hypersonic static-site generator written in Rust. 🚀 💊 🔥

MANDY 🚀 💊 🔥 A hypersonic static-site generator written in Rust. 🚀 💊 🔥 ABOUT 📚 Mandy is fast, easy to use, easy to deploy, and very flexible! Ge

rublog /rʌblɑg/ is a static blog generator written in Rust
rublog /rʌblɑg/ is a static blog generator written in Rust

README README About rublog demo DEMO Install use Initialize from rublog-template rublog command Publishing the web page Development Plan TOML Front Ma

⚡ A Blazingly-Fast Static Site Generator, built with Rust.
⚡ A Blazingly-Fast Static Site Generator, built with Rust.

Stuart A Blazingly-Fast Static Site Generator. Download Now » Stuart is a very fast and flexible static site generator, with build times as low as 0.1

A fast static site generator in a single binary with everything built-in. https://www.getzola.org

zola (né Gutenberg) A fast static site generator in a single binary with everything built-in. Documentation is available on its site or in the docs/co

static site generator from markdown files.

Mdblog Static site generator from markdown files with features: TeX style math support file path is the post url file name is the post title post can

A fast static site generator in a single binary with everything built-in. https://www.getzola.org

zola (né Gutenberg) A fast static site generator in a single binary with everything built-in. Documentation is available on its site or in the docs/co

the best static site generator

the best static site generator you've ever seen

Oinky - A blazing fast, data-oriented static site generator.

Oinky Oinky is a static site generator, written in Rust, that compiles Handlebars templates and Markdown files into a static site. Oinky also enables

A file format-agnostic static site generator

mksite A file format-agnostic static site generator Installation If you already have Rust and Cargo installed: cargo install mksite Alternatively, you

Rust-blog - Educational blog posts for Rust beginners

pretzelhammer's Rust blog 🦀 I write educational content for Rust beginners and Rust advanced beginners. My posts are listed below in reverse chronolo

A minimal and flexible blog generator based on GitHub Gists.
A minimal and flexible blog generator based on GitHub Gists.

gisture Utilizing GitHub Gists as a Blogging Platform A minimal and flexible blog generator based on GitHub Gists with SEO, Templating, Syntax Highlig

A highly customizable Changelog Generator that follows Conventional Commit specifications ⛰️
A highly customizable Changelog Generator that follows Conventional Commit specifications ⛰️

git-cliff can generate changelog files from the Git history by utilizing conventional commits as well as regex-powered custom parsers. The changelog template can be customized with a configuration file to match the desired format.

Owner
MrNothing233
MrNothing233
Serve a static site, single page application or just a static file with Rust

cargo-server tl;dr: Does the same as "python -m http.server" or "npx serve" but for Rust ecosystem. cargo-server helps you serve a static site, single

Raphael Amorim 18 Oct 14, 2022
An ultra simple static site generator designed to appeal to technical as well as non technical users.

Hulk is an ultra simple static site generator designed to appeal to both technical and non technical users.

Bilal Tariq 1 Dec 27, 2021
Static site generator written in Rust

Sedum is a static site generator written in Rust. It can be used locally or with a service like Netlify to generate websites on the fly. Usage Local P

Elly 1 Jan 5, 2022
A hypersonic static-site generator written in Rust. 🚀 💊 🔥

MANDY ?? ?? ?? A hypersonic static-site generator written in Rust. ?? ?? ?? ABOUT ?? Mandy is fast, easy to use, easy to deploy, and very flexible! Ge

✭ ANGEL DOLLFACE ✭ 5 Jun 30, 2023
rublog /rʌblɑg/ is a static blog generator written in Rust

README README About rublog demo DEMO Install use Initialize from rublog-template rublog command Publishing the web page Development Plan TOML Front Ma

null 10 Jul 24, 2023
A fast static site generator in a single binary with everything built-in. https://www.getzola.org

zola (né Gutenberg) A fast static site generator in a single binary with everything built-in. Documentation is available on its site or in the docs/co

Zola 10.1k Jan 5, 2023
static site generator from markdown files.

Mdblog Static site generator from markdown files with features: TeX style math support file path is the post url file name is the post title post can

Fu 51 Dec 6, 2022
the best static site generator

the best static site generator you've ever seen

Anirudh Balaji 14 Jan 24, 2022
A file format-agnostic static site generator

mksite A file format-agnostic static site generator Installation If you already have Rust and Cargo installed: cargo install mksite Alternatively, you

Michelle S. 5 Nov 25, 2022
😋 Make your own blog!

Leven Leven is a lightweight Markdown-based static site generator for blogs. It's a lot like Jekyll or Hugo, but it's much simpler, much faster, and m

null 55 Oct 6, 2022