ssg 0.0.12

A Fast and Flexible open-source static site generator (ssg) written in Rust.
Documentation

Shokunin (職人) Static Site Generator

A Fast and Flexible open-source static site generator (ssg) written in Rust 🦀

Part of the Mini Functions family of libraries.

Banner of the Shokunin (職人) Static Site Generator

Made With Rust Crates.io Lib.rs Docs.rs License Codecov

WebsiteDocumentationReport BugRequest FeatureContributing Guidelines

divider

Overview 📖

Shokunin (職人) Static Site Generator is a highly-optimized, Rust-based static site generator (ssg) that aims to provide an easy-to-use and powerful tool for building professional static websites and blogs.

The library extracts metadata and content to generate static HTML files from Markdown, YAML, JSON, and TOML. It also supports HTML themes and custom templates to help you create high quality websites with ease.

Features ✨

Shokunin (職人) Static Site Generator feature highlights include:

  • Blazing fast and flexible static site generator written in Rust 🦀
  • Built-in support for GitHub Flavored Markdown (GFM).
  • Built-in support for Google Analytics and Bing Analytics.
  • Compatible with various HTML themes and Premium templates.
  • Generates Atom and RSS feeds for your blog posts.
  • Generates minified versions for optimal performance and SEO.
  • Includes a built-in Rust development server for local development and testing.
  • Supports multiple content formats, including Markdown, YAML, JSON, TOML, XML, etc.
  • Built-in support for sitemap generation, robots.txt generation, canonical name (CNAME) records and custom 404 pages.

Table of Contents 📚

Getting Started 🚀

It takes just a few minutes to get up and running with Shokunin (職人) Static Site Generator.

Installation

To install Shokunin (職人) Static Site Generator, you need to have the Rust toolchain installed on your machine. You can install the Rust toolchain by following the instructions on the Rust website.

Once you have the Rust toolchain installed, you can install Shokunin (職人) Static Site Generator using the following command:

cargo install ssg

For simplicity, we have given Shokunin (職人) Static Site Generator a simple alias ssg which can stand for Shokunin (職人) Site Generator or Static Site Generator.

You can then run the help command to see the available options and commands:

ssg --help

Requirements

The minimum supported Rust toolchain version is currently Rust 1.69.0 or later (stable). It is recommended that you install the latest stable version of Rust.

Platform support

Shokunin (職人) Static Site Generator is supported and tested on the following platforms:

Tier 1 platforms

Operating System Target Description
Linux aarch64-unknown-linux-gnu 64-bit Linux systems on ARM architecture
Linux i686-unknown-linux-gnu 32-bit Linux (kernel 3.2+, glibc 2.17+)
Linux x86_64-unknown-linux-gnu 64-bit Linux (kernel 2.6.32+, glibc 2.11+)
macOS x86_64-apple-darwin 64-bit macOS (10.7 Lion or later)
Windows i686-pc-windows-gnu 32-bit Windows (7 or later)
Windows i686-pc-windows-msvc 32-bit Windows (7 or later)
Windows x86_64-pc-windows-gnu 64-bit Windows (7 or later)
Windows x86_64-pc-windows-msvc 64-bit Windows (7 or later)

Tier 2 platforms

Operating System Target Description
Linux aarch64-unknown-linux-musl 64-bit Linux systems on ARM architecture
Linux arm-unknown-linux-gnueabi ARMv6 Linux (kernel 3.2, glibc 2.17)
Linux arm-unknown-linux-gnueabihf ARMv7 Linux, hardfloat (kernel 3.2, glibc 2.17)
Linux armv7-unknown-linux-gnueabihf ARMv7 Linux, hardfloat (kernel 3.2, glibc 2.17)
Linux mips-unknown-linux-gnu MIPS Linux (kernel 2.6.32+, glibc 2.11+)
Linux mips64-unknown-linux-gnuabi64 MIPS64 Linux (kernel 2.6.32+, glibc 2.11+)
Linux mips64el-unknown-linux-gnuabi64 MIPS64 Linux (kernel 2.6.32+, glibc 2.11+)
Linux mipsel-unknown-linux-gnu MIPS Linux (kernel 2.6.32+, glibc 2.11+)
macOS aarch64-apple-darwin 64-bit macOS (10.7 Lion or later)
Windows aarch64-pc-windows-msvc 64-bit Windows (7 or later)

The GitHub Actions shows the platforms in which the Shokunin (職人) Static Site Generator library tests are run.

Documentation

ℹ️ Info: Please check out our website for more information. You can find our documentation on docs.rs, lib.rs and crates.io.

Usage 📖

Command Line Interface (CLI)

The Shokunin (職人) Static Site Generator library runs in a Terminal window and can be used to generate a static website.

Here’s the first command you can enter in your Terminal window to run Shokunin (職人) Static Site Generator:

ssg  --new=mysite --content=content --template=template --output=output --serve=public

or

ssg  -n=mysite -c=content -t=template -o=output -s=public

This command will create a new website with the name mysite in the current directory. It will use the content directory to gather the website content and the template directory to generate the website files. It will serve the website directly from the mysite directory.

Arguments

  • -n, --new: The name of the new website. (required)
  • -c, --content: The directory containing the website content. (required)
  • -t, --template: The directory containing the website templates. (required)
  • -o, --output: The directory where the generated website files will be saved temporarily. (required)
  • -s, --serve: Run the development server. (optional). The directory from which the website will be served.

In your project

To use the Shokunin (職人) Static Site Generator library in your project, add the following to your Cargo.toml file:

[dependencies]
shokunin = "0.0.12"

Add the following to your main.rs file:

extern crate ssg;
use ssg::*;

then you can use the Shokunin (職人) Static Site Generator functions in your application code.

Examples

To get started with Shokunin (職人) Static Site Generator, you can use the examples provided in the examples directory of the project.

To run the examples, clone the repository and run the following command in your terminal from the project root directory.

cargo run --example example

The command will generate a static website based on the configuration details in the examples directory.

use ssg::compiler::compile;
use std::path::Path;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Define the paths to the build, site, source and template directories.
    let build_path = Path::new("examples/example.com/build");
    let site_path = Path::new("examples/example.com/public");
    let content_path = Path::new("examples/example.com/contents");
    let template_path = Path::new("examples/example.com/templates");

    compile(build_path, content_path, site_path, template_path)?;

    Ok(())
}

The main() function in this code compiles a website from the content directory, using the template directory to generate the website files. The compiled website is saved in the build directory and served directly from the example.com directory.

Args

  • build_path: The path to the directory where the compiled website will be saved.
  • content_path: The path to the directory containing the website content.
  • site_path: The path to the directory where the generated website files will be served from.
  • template_path: The path to the directory containing the website templates.

Return value

The main() function returns a Result. If the compilation is successful, the Result will be Ok(()). If there is an error, the Result will be Err(e), where e is a Box.

Semantic Versioning Policy 🚥

For transparency into our release cycle and in striving to maintain backward compatibility, Shokunin (職人) Static Site Generator follows semantic versioning.

License 📝

The project is licensed under the terms of both the MIT license and the Apache License (Version 2.0).

Contribution 🤝

We welcome all people who want to contribute. Please see the contributing instructions for more information.

Contributions in any form (issues, pull requests, etc.) to this project must adhere to the Rust's Code of Conduct.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Acknowledgements 💙

A big thank you to all the awesome contributors of Shokunin (職人) for their help and support.

A special thank you goes to the Rust Reddit community for providing a lot of useful suggestions on how to improve this project.