cargo install mdblog (将会生成可执行文件mdblog)
root@racknerd-626f077:~# cd /usr/local/
root@racknerd-626f077:/usr/local# mdblog init mdblog-site (会在当前目录下,生成子目录:mdblog-site)
root@racknerd-626f077:/usr/local# cd mdblog-site
root@racknerd-626f077:/usr/local/mdblog-site# ls
config.toml media posts _themes
root@racknerd-626f077:/usr/local/mdblog-site# nano config.toml (把posts_per_page的值改为3)
root@racknerd-626f077:/usr/local/mdblog-site# mdblog build (此即生成/更新静态网站的根目录的命令)
root@racknerd-626f077:/usr/local/mdblog-site# ls
_build config.toml media posts _themes
(生成了_build目录)
root@racknerd-626f077:/usr/local/mdblog-site# cd _build
root@racknerd-626f077:/usr/local/mdblog-site/_build# ls
atom.xml index.html media posts static tags tags.html
root@racknerd-626f077:/usr/local/mdblog-site/_build# python3 -m http.server 1234
新建源帖:
root@racknerd-626f077:/usr/local/mdblog-site/_build# cd ..
root@racknerd-626f077:/usr/local/mdblog-site# ls
_build config.toml media posts _themes
root@racknerd-626f077:/usr/local/mdblog-site# cd posts
root@racknerd-626f077:/usr/local/mdblog-site/posts# nano 美丽的草原.md
root@racknerd-626f077:/usr/local/mdblog-site/posts# cat 美丽的草原.md
显示:
created: 2024-11-12T16:20:44.665202118Z
tags: [music, life]
此处写正文或html codes.
root@racknerd-626f077:/usr/local/mdblog-site/posts# cd ..
root@racknerd-626f077:/usr/local/mdblog-site# mdblog build
演示网站:
https://fluffy-lamington-55418c.netlify.app/ ,此为我在windows桌面系统上搭建的网站,然后把该静态网站的根目录上传到netlify.com后,得到的网址。在windows桌面系统上搭建的这个网站有点不正常。比如:帖子
https://fluffy-lamington-55418c.netlify.app/posts\pretty-grassland.html,
要手动把\ 改为/ 才行。
https://sweet-squirrel-eeccfc.netlify.app/ ,此为我在linux vps上搭建的网站,进入该静态网站的根目录,用命令tar cvf mb.tar.gz . 把根目录打包为mb.tar.gz文件,然后在此目录下运行
python3 -m http.server 1234 ,然后在本地机器的浏览器里访问vps-public-ip:1234/mb.tar.gz ,
以下载mb.tar.gz文件到本地机器,然后解压得到mb目录,然后访问https://app.netlify.com/drop,定位mb目录,上传mb目录的内容,从而得到的网址。
http://mbrs.briten.top ,这个是我替linux vps上搭建的网站所绑定的域名,域名指向我的linux vps上的/usr/local/mdblog-site/_build目录。
可见,在windows上,搭建各种编程语言环境其实是不太合适的,经常遇到各种坑,最好是在mac或linux桌面系统或linux vps上操作。
项目地址: https://github.com/FuGangqiang/mdblog.rs
https://fugangqiang.github.io/posts/rust/%E7%94%A8%20mdblog%20%E6%9E%84%E5%BB%BA%E9%9D%99%E6%80%81%E5%8D%9A%E5%AE%A2.html
-------------------------------------------------
在linux vps上,搭建基于rust的静态博客程序morpho
cd ~
首先安装rust环境,需要是nightly版。然后,
cargo install morpho
$ morpho -h
static site generator from markdown files
USAGE:
morpho <SUBCOMMAND>
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
SUBCOMMANDS:
build Build the site static files
help Prints this message or the help of the given subcommand(s)
init Initialize the site directory layout
new Create a site post
serve Serve the site, rebuild on change
theme Blog theme operations
you can also check the subcommand usage:
$ morpho serve -h
Serve the site, rebuild on change
USAGE:
morpho serve [OPTIONS]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-p, --port <port> Serve the site at http://127.0.0.1:<port> [default: 5000]
$ morpho init morpho-site (此命令会生成子目录morpho-site)
cd morpho-site
morpho build (此即生成/更新静态网站的根目录的命令,会在当前目录下,生成public目录)
the site static files are build into the subdir public.
root@racknerd-626f077:~/morpho-site# ls
config.toml media posts public themes
root@racknerd-626f077:~/morpho-site# ls public
index.html media posts static tags
root@racknerd-626f077:~/morpho-site#
新建源帖:
root@racknerd-626f077:~/morpho-site# cd posts
root@racknerd-626f077:~/morpho-site/posts# nano "美丽的草原,我的家.md"
root@racknerd-626f077:~/morpho-site/posts# cat
"美丽的草原,我的家.md"
显示:
created = "2024-11-14T19:55:20+00:00"
tags = ["music", "life"]
此处写正文或 html codes.
root@racknerd-626f077:~/morpho-site/posts# cd ..
root@racknerd-626f077:~/morpho-site# nano config.toml
( 修改posts_per_page的值为3)
root@racknerd-626f077:~/morpho-site# morpho build
演示网站:https://morpho-blog-of-brite-d6m3wut36-luckypoems-projects.vercel.app
项目地址:https://github.com/luciusmagn/morpho
No comments:
Post a Comment