开始使用zola博客

·
Table of Contents

安装zola

git clone https://github.com/getzola/zola.git
cd zola
cargo install --path . --locked
zola --version

配置博客

zola init blog
cd blog
git submodule add https://github.com/salif/linkita.git themes/linkta
# The URL the site will be built for
base_url = "https://blog.example.com"

title = "peter的博客"
description = "学海无涯"
default_language = "zh"
generate_rss = true

# Whether to automatically compile all Sass files in the sass directory
compile_sass = false

# theme = "even"
theme = "linkita"

# Whether to do syntax highlighting
# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola
highlight_code = true
highlight_theme = "monokai"

# Whether to build a search index to be used later on by a JavaScript library
build_search_index = false

ignored_content = ["*.sw?"]

taxonomies = [
    {name = "categories", rss = true, paginate_by = 10},
    {name = "tags", rss = false, paginate_by = 10},
]

[extra]
# Put all your custom variables here

[extra.author]
name = "peter xiaoli"
email = "[email protected]"

新建博客脚本

#!/bin/bash
# Copyright (c) 2025 peterxiaoli<[email protected]>. All rights reserved.
# Use of this source is governed by General Public License that can be found
# in the LICENSE file.

set -xe
# Create a new article template.

ARTICLE=$1
if [ -z "${ARTICLE}" ]; then
  echo "Usage $0 article-name"
  exit 1
fi
TIMESTAMPE=$(date --rfc-3339=seconds)
FILENAME="content/$(date +%Y-%m-%d)-${ARTICLE}.md"
URL_PATH="$(date +%Y)/$(date +%m)/${ARTICLE}"
echo "TIMESTMAP: ${TIMESTAMPE}"
echo "FILENAME: ${FILENAME}"
echo "URL_PATH: ${URL_PATH}"

if [ ! -f "${FILENAME}" ]; then
  cat > "${FILENAME}" << EOF
+++
title = "${ARTICLE}"
description = ""
date = ${TIMESTAMPE}
path = "${URL_PATH}"
[taxonomies]
categories = []
+++
EOF
fi

Categories