static site generator from markdown files.

Overview

Mdblog

crate Docs MIT/Apache2 licensed dependency status Build Status

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 be hidden(link does not be insert into index/tag page)

you can check the demo site to learn the usages of mdblog.

Install

mdblog is implemented by rust language(2018 edition), so you need cargo command:

cargo +nightly install mdblog

mdblog will be installed in your cargo binary directory(~/.cargo/bin/).

CLI

mdblog can be use as a command:

$ mdblog -h
static site generator from markdown files

USAGE:
    mdblog <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

SUBCOMMANDS:
    build    Build the blog static files
    help     Prints this message or the help of the given subcommand(s)
    init     Initialize the blog directory layout
    new      Create a blog post
    serve    Serve the blog, rebuild on change
    theme    Blog theme operations

you can also check the subcommand usage:

$ mdblog serve -h
Serve the blog, rebuild on change

USAGE:
    mdblog serve [OPTIONS]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -p, --port <port>    Serve the blog at http://127.0.0.1:<port> [default: 5000]

init blog

$ mdblog init myblog

blog directory(myblog) layout is initialized:

myblog
├── config.toml
├── media
├── posts
│   ├── hello.md
│   └── math.md
└── _themes
  • config.toml: blog config file
  • media: blog media directory
  • posts: blog posts directory
  • posts/hello.md: a markdown style post
  • _themes: blog themes directory

build blog

$ cd myblog
$ mdblog build

the blog static files are build into the subdir _build, the current blog directory(myblog) layout is:

myblog
├── config.toml
├── media
├── posts
│   ├── hello.md
│   └── math.md
├── _themes
└── _builds
  • _builds: generated static-site top directory

serve blog

$ mdblog serve

open the site index page automatically, and re-generate your static-site when you add or change content,

new post

create a new post titled another:

$ mdblog new another

a new markdown file posts/another.md is created, you can edit it for the new post.

refresh the index page, you will find the new post.

config.toml

site_url = ""
site_name = "Mdblog"
site_motto = "Simple is Beautiful!"
footer_note = "Keep It Simple, Stupid!"
media_dir = "media"
build_dir = "_build"
theme = "simple"
theme_root_dir = "_themes"
rebuild_interval = 2
posts_per_page = 20
Comments
  • wrap post header with

    wrap post header with "---"

    I tried to wrap the header with "---" just like hexo and jekyll do, so those who these blog engines can switch to mdblog.

    Other update:

    • fix typo
    • update dependencies and switch to rust 2021
    • output the path of the file with error while occurring PostHeadPaser error
    opened by Sciroccogti 5
  • Add alternative title in post headers

    Add alternative title in post headers

    How about adding an element on the header of the post to set the title.

    Now mdblog get the post title from the file name, but this has a lot fo limits as the file names are bad with punctuation or with special characters.

    And if for the title you want, the case is important, it can be missed on a file name (just in case of rename).

    This new attribute should be optional, so mdblog will continue to use the file name as the blog title, but if the user set the title attribute, than this value is used to set the post title.

    I think the change is pretty easy to make, and I can help if this is accepted.

    opened by alexmario74 3
  • 请问/页面默认的title怎么改掉(Fu),其它页面的没有问题

    请问/页面默认的title怎么改掉(Fu),其它页面的没有问题

    base.tpl: 主题里所有能看到的Fu都已经改了,或者在rust源码里面? 或者应该把它(网站名)放到config.toml? 另外还有favicon.ico和logo.png的路径。

    <!doctype html>
    <html>
    <head>
      <meta charset="utf-8">
      <link rel="icon" href="/media/static/img/favicon.ico">
      <link rel="stylesheet" href="/static/css/main.css">
      {% block css %}{% endblock css %}
      <title>{{ title }}</title>
    </head>
    <body>
    

    生成的html

    <!doctype html>
    <html>
    <head>
      <meta charset="utf-8">
      <link rel="icon" href="/media/static/img/favicon.ico">
      <link rel="stylesheet" href="/static/css/main.css">
      
      <title>Fu</title>
    </head>
    <body>
    
    enhancement 
    opened by biluohc 3
  • could not compile mdblog

    could not compile mdblog

    I compile it on centos7.9 with errors:

    error[E0432]: unresolved import `tera::CtxThreadSafe`
      --> /root/.cargo/registry/src/mirrors.sjtug.sjtu.edu.cn-4f7dbcce21e258a2/mdblog-0.20.2/src/lib.rs:27:21
       |
    27 | use tera::{Context, CtxThreadSafe, Tera};
       |                     ^^^^^^^^^^^^^ no `CtxThreadSafe` in the root
    
    error[E0107]: this struct takes 0 generic arguments but 1 generic argument was supplied
       --> /root/.cargo/registry/src/mirrors.sjtug.sjtu.edu.cn-4f7dbcce21e258a2/mdblog-0.20.2/src/lib.rs:488:42
        |
    488 |     fn get_base_context(&self) -> Result<Context<CtxThreadSafe>> {
        |                                          ^^^^^^^--------------- help: remove these generics
        |                                          |
        |                                          expected 0 generic arguments
        |
    
    
    opened by 1024chen 2
  • fix now it check if body is empty

    fix now it check if body is empty

    Hi, I noticed this small issue and thought to just fix it without open any issue.

    Hope this helps.

    Edit: I realized I used the post and not the body to for the check, I changed, but for some reason the commit is not showing the proper diff on the commit.

    opened by alexmario74 1
  • Failed to install with `cargo install mdblog`. Cause: incompatible stable compiler. Fix is documented.

    Failed to install with `cargo install mdblog`. Cause: incompatible stable compiler. Fix is documented.

    Fix

    First make shure you have the rust nightly toolchain installed.

    rustup show
    

    should show text like

    installed toolchains
    --------------------
    
    stable-###-darwin
    nightly-###-darwin
    

    If the nightly toolchain does not show, install it with rustup.

    rustup install nightly
    

    This fixes the error if one has the nightly rust channel installed:

    cargo +nightly install mdblog
    

    @FuGangqiang

    Please include the solution in your crate description. Thankyou for your work <(^_^)> I was looking for a static site generator written in rust. mdblog.rs looks very promising.

    Error Report

    error: failed to run custom build command for `pear_codegen v0.1.2`
    
    Caused by:
      process didn't exit successfully: `###/build-script-build` (exit code: 101)
    --- stderr
    Error: Pear requires a nightly or dev version of Rust.
    Installed version is: 1.41.0 (2020-01-27). Minimum required: 1.31.0-nightly (2018-10-05).
    thread 'main' panicked at 'Aborting compilation due to incompatible compiler.', ### pear_codegen-0.1.2/build.rs:31:13
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
    
    warning: build failed, waiting for other jobs to finish...
    error: failed to compile `mdblog v0.17.0`, intermediate artifacts can be found at `/var/folders/x4/###`
    
    Caused by:
      build failed
    
    opened by LittleEntity 1
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
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
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
the best static site generator

the best static site generator you've ever seen

Anirudh Balaji 14 Jan 24, 2022
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
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
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
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
Sūshì is a simple but customizable static site generator / blog generator written in Rust

sūshì Sūshì is a simple but customizable static site generator / blog generator written in Rust. Installation Install with Cargo (Recommended) cargo i

MrNothing233 2 Mar 20, 2022
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

null 7 Dec 18, 2022
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
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
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
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 10, 2023
the best static site generator

the best static site generator you've ever seen

Anirudh Balaji 14 Jan 24, 2022
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
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
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

Asko Nõmm 4 Jun 18, 2022
⚡ 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

William Henderson 5 Nov 25, 2022