HUGO搭建笔记
通过Git推送到GitHub
安装git,下一步点到底 https://git-scm.com/install/windows
把 GitHub 仓库克隆到本地
| |
- 在本地写文章
- 用 VS Code 打开这个文件夹。
- 在 content/posts/ 目录下新建 .md 文件,用 Markdown 写文章。
- 如果需要图片,放到 static/images/ 目录下。
- 推送到 GitHub
在本地终端(项目目录下)执行:
| |
你的代码就会推送到 GitHub。
- 服务器自动拉取并构建
推送后,你需要让服务器上的 /root/my-blog 目录自动拉取最新代码并重新生成网站。
在服务器上执行:
| |
执行后会让打开编辑器,这里选nano,在文件末尾添加一行(每 5 分钟检查一次更新):
| |
这行命令的含义:
*/5 * * * *:每5分钟执行一次。
cd /root/my-blog:进入博客目录。
git pull:从 GitHub 拉取最新代码。
hugo –minify:重新生成静态网站。
验证定时任务是否添加成功
| |
会显示你刚才添加的那一行,说明已生效。
Welcome to Hugo theme Stack. This is your first post. Edit or delete it, then start writing!
For more information about this theme, check the documentation: https://stack.jimmycai.com/
Want a site like this? Check out hugo-theme-stack-stater
Photo by Pawel Czerwinski on Unsplash
