有前端基础,会Markdown、会HTML和CSS,选择 Hexo
有Vue基础可以选择 vuePress 或者 vitePress
会react可以选择 docusaurus
会Go可以选择 Hugo
会Rust可以选择 Zola
会Ruby可以选择 Jekyll
会PHP可以考虑使用 WordPress
其他开源项目:docsify、GitBook
mdBook 是一个命令行工具,可以将 Markdown 文档,变成 HTML 网站。 这样的工具,用在产品信息或是 API 文档, 教程, 课件资料等等场景。
https://segmentfault.com/q/1010000042459229
docsify简单使用
1、下载docsify并解压
# 下载
wget https://codeload.github.com/docsifyjs/docsify/zip/refs/heads/master -o docsify-master.zip
# 下载unzip
yum -y install unzip
# 解压
unzip docsify-master.zip
2、nginx部署
2.1、nginx安装(略)
2.2、使用mv命令移动docsify-master文件到nginx的html目录
2.3、nginx.conf配置
location / {
root 'docsify所在的目录';
index index.html index.htm;
#add_header Cache-Control "no-cache, no-store, must-revalidate";
#add_header Pragma "no-cache";
#add_header Expires 0;
}
2.4、重启nginx
nginx -s reload
2.5、通过浏览器访问项目
3、修改docsify文件
3.1、修改index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<meta charset="UTF-8"/>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/lib/themes/dark.css">
</head>
<body>
<div id="app">Loading...</div>
<script>
window.$docsify = {
name: 'snail',
loadSidebar: 'zh-cn/_sidebar.md',
//loadSidebar: true,
//loadNavbar: true,
search: {
placeholder: '搜索',
noData: '找不到结果',
depth: 2, // 搜索标题的最大层级, 1 - 6
namespace: 'docsify',
pathNamespaces: ['/zh-cn'],
}
};
</script>
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/emoji.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/zoom-image.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code/dist/docsify-copy-code.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-bash.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-php.min.js"></script>
</body>
</html>
3.2、根据情况修改_sidebar.md、_navbar.md
3.3、更换css、js使用国内cdn资源
<!-- 更换css、js使用国内cdn资源 -->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<meta charset="UTF-8"/>
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/docsify/4.13.0/themes/dark.min.css">
<title>snail</title>
</head>
<body>
<div id="app">Loading...</div>
<script>
window.$docsify = {
name: 'snail',
//basePath: 'zh-cn/',
loadSidebar: 'zh-cn/_sidebar.md',
//loadSidebar: '_sidebar.md',
//loadSidebar: true,
//loadNavbar: true,
search: {
placeholder: '搜索',
noData: '找不到结果',
depth: 2, // 搜索标题的最大层级, 1 - 6
namespace: 'docsify',
pathNamespaces: ['/zh-cn'],
}
};
</script>
<script src="https://cdn.bootcdn.net/ajax/libs/docsify/4.13.0/docsify.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/docsify/4.13.0/plugins/search.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/docsify/4.13.0/plugins/emoji.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/docsify/4.13.0/plugins/zoom-image.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/docsify-copy-code/2.1.1/docsify-copy-code.min.js"></script>
</body>
</html>
详见:docsify
Hugo简单使用
1、安装go
# 1、访问go下载页面:https://go.dev/dl/
# 2、下载go
wget https://go.dev/dl/go1.21.6.linux-amd64.tar.gz
# 3、解压
tar -xf go1.21.6.linux-amd64.tar.gz
# 4、移动go到/usr/local/go
mv go /usr/local/go
# 5、添加到环境变量
vi /root/.bash_profile
# 6、/root/.bash_profile文件内容:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
GO_PATH=/usr/local/go/bin
PATH=$PATH:$HOME/bin:$GO_PATH
export PATH
# 7、使环境变量生效
source /root/.bash_profile
# 8、在任意目录执行
go version
2、安装Hugo
# 1、下载
wget https://github.com/gohugoio/hugo/archive/refs/tags/v0.121.2.tar.gz
# 2、解压
tar -xf v0.121.2.tar.gz
# 3、将hugo文件移动到/usr/local/bin/
mv hugo /usr/local/bin/
# 4、生成站点
hugo new site test
# 5、创建一个 about 页面
hugo new about.md
# 6、编辑about.md,删除“draft = true”这行
# 7、安装皮肤
yum -y install git
cd themes
git clone https://github.com/spf13/hyde.git
# 8、运行hugo,浏览器里打开:http://localhost:1313
hugo server --theme=hyde
# 9、部署,执行 Hugo 命令生成最终页面
# 同时会创建public目录,该目录为生成的页面
# 我们可以将public目录的内容部署到nginx中
hugo --theme=hyde
详见:
mdBook简单使用
1、安装Rust
1.1、配置镜像
下载依赖太慢了? - Rust语言圣经(Rust Course)
# 创建/root/.cargo/config.toml文件
# 选择的镜像源
# 喜欢哪个用哪个吧,没有注释掉的那个就是你选择的
#replace-with = 'ustc'
replace-with = 'tuna'
#replace-with = 'sjtu'
#replace-with = 'rustcc'
#replace-with = 'aliyun'
# 源码地址
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
# 镜像地址
# 清华大学
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
# 中国科学技术大学
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
# 上海交通大学
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
# rustcc社区
[source.rustcc]
registry = "git://crates.rustcc.cn/crates.io-index"
# 阿里云
[source.aliyun]
registry = "https://code.aliyun.com/rustcc/crates.io-index"
1.2、安装
# rust下载页:https://www.rust-lang.org/tools/install
# 下载
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
执行命令的结果如下:
中途需要选择
- 1) Proceed with installation (default) =》默认安装
- 2) Customize installation =》自定义安装
- 3) Cancel installation =》取消安装
info: downloading installer
Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure
Welcome to Rust!
This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.
Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:
/root/.rustup
This can be modified with the RUSTUP_HOME environment variable.
The Cargo home directory is located at:
/root/.cargo
This can be modified with the CARGO_HOME environment variable.
The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:
/root/.cargo/bin
This path will then be added to your PATH environment variable by
modifying the profile files located at:
/root/.profile
/root/.bash_profile
/root/.bashrc
You can uninstall at any time with rustup self uninstall and
these changes will be reverted.
Current installation options:
default host triple: x86_64-unknown-linux-gnu
default toolchain: stable (default)
profile: default
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1
info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2023-12-28, rust version 1.75.0 (82e1608df 2023-12-21)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
14.3 MiB / 14.3 MiB (100 %) 9.1 MiB/s in 1s ETA: 0s
info: downloading component 'rust-std'
23.6 MiB / 23.6 MiB (100 %) 9.1 MiB/s in 2s ETA: 0s
info: downloading component 'rustc'
61.4 MiB / 61.4 MiB (100 %) 9.0 MiB/s in 7s ETA: 0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
14.3 MiB / 14.3 MiB (100 %) 491.2 KiB/s in 31s ETA: 0s
info: installing component 'rust-std'
23.6 MiB / 23.6 MiB (100 %) 3.7 MiB/s in 20s ETA: 0s
4 IO-ops / 4 IO-ops (100 %) 1 IOPS in 3s ETA: 0s
info: installing component 'rustc'
61.4 MiB / 61.4 MiB (100 %) 8.0 MiB/s in 24s ETA: 0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'
stable-x86_64-unknown-linux-gnu installed - (timeout reading rustc version)
Rust is installed now. Great!
To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).
To configure your current shell, run:
source "$HOME/.cargo/env"
最后执行命令:source "$HOME/.cargo/env"
1.3、命令
cargo build:构建项目
cargo run:运行项目
cargo test:测试项目
cargo doc:为项目构建文档
cargo publish:发布库
cargo --version:查看版本
Getting started - Rust Programming Language
2、安装mdBook
# mdBook下载页:https://github.com/rust-lang/mdBook/releases
# 下载
wget https://github.com/rust-lang/mdBook/archive/refs/tags/v0.4.36.tar.gz
# 解压
tar -xf mdBook-0.4.36.tar.gz
# 重命名
mv mdBook-0.4.36 mdBook
# 进入mdBook目录
cd mdBook
# 运行项目
# cargo run,生成mdbook文件在当前目录下的target/debug/mdbook
# 构建项目
# cargo build --release,生成mdbook文件在当前目录下的target/release/mdbook
cargo build --release
# 复制mdbook到/usr/local/bin/目录下
cp target/release/mdbook /usr/local/bin/
3、mdbook命令
# mdbook命令
Creates a book from markdown files
Usage: mdbook [COMMAND]
Commands:
init Creates the boilerplate structure and files for a new book
build Builds a book from its markdown files
test Tests that a book's Rust code samples compile
clean Deletes a built book
completions Generate shell completions for your shell to stdout
watch Watches a book's files and rebuilds it on changes
serve Serves a book at http://localhost:3000, and rebuilds it on changes
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
# 初始化项目
mdbook init mybook
# 启动服务
mdbook serve
# 显示结果
2024-01-15 22:25:59 [INFO] (mdbook::book): Book building has started
2024-01-15 22:25:59 [INFO] (mdbook::book): Running the html backend
2024-01-15 22:25:59 [INFO] (mdbook::cmd::serve): Serving on: http://localhost:3000
2024-01-15 22:25:59 [INFO] (mdbook::cmd::watch): Listening for changes...
2024-01-15 22:25:59 [INFO] (warp::server): Server::run; addr=[::1]:3000
2024-01-15 22:25:59 [INFO] (warp::server): listening on http://[::1]:3000
# 使用curl命令访问
curl localhost:3000
详见: