用hugo快速搭建博客
- 准备好域名和服务器。没有域名或未备案的话可以先用ip访问。
-
unbuntu 20.04系统
-
下载hugo
https://github.com/gohugoio/hugo/releases
hugo_0.81.0_Linux-64bit.deb -
选一个干净的文件夹,生成博客文件目录。
hugo new site abc.com
-
git init .
起个git仓库 -
去 themes.gohugo.io 选一个喜欢的主题
-
按主题的流程进行操作。比如:
cd abc.com
git submodule add https://github.com/AmazingRise/hugo-theme-diary.git themes/diary
用这个配置代替默认的config.toml
,并作必要的修改。
https://github.com/AmazingRise/hugo-theme-diary/blob/master/exampleSite/config.toml -
起测试服
hugo server
会在1313端口起http测试服。 -
正式生成网页文件
hugo
会生成public
文件夹,包含正式的网页文件。
起nginx,指向这个public
目录即可。 -
发布文章
hugo new posts/xxx.md
会在content
目录下生成posts
文件夹和xxx.md。
xxx.md默认内容为--- title: "xxxx" date: xxxx draft: true ---
自行修改,draft改为false。再填上要发布的md内容即可。
最后再次运行hugo更新public。 -
md里的图片问题
在static目录下创建images目录。md里图片链接做成images/xxx.jpg
即可。