利用git实现快速更新hugo博文 @ 欧振江 | 2021-08-23T21:47:51+08:00 | 1 分钟阅读 | 更新于 2021-08-23T21:47:51+08:00

Cut out summary from your post content here.

hugo使用脚本发布文章

前言

由于Hexo博客的生成速度太慢了,所以我开始使用Hugo博客 https://weirdchun.github.io/

写博客

当使用Hugo博客后,写文章的姿势

hugo new post/202001-xxxxxx.md

生成静态文件 使用hugo命名,就会在public生成博客页面

hugo

发布博客 进入public文件

cd public

常规git操作

git add .
git commit -m "blog"
git remote add origin https://github.com/Weirdchun/Weirdchun.github.io.git
git push -u origin master

使用脚本发布博客

新建deploy.sh文件

每次发布都得进行上面四步,太麻烦了,使用脚本代替!

​ 1、在MyBlog根站点新建一个文件命名deploy.sh,写入git操作代码

#!/bin/bash

echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"

# Build the project.
hugo # if using a theme, replace by `hugo -t <yourtheme>`

# Go To Public folder
cd public
# Add changes to git.
git add -A

# Commit changes.
msg="rebuilding site `date`"
if [ $# -eq 1 ]
  then msg="$1"
fi
git commit -m "$msg"

# Push source and build repos.
git push github master

# Come Back
cd ..


双击deploy.sh文件

双击后将开始部署,但是得输入Github账号与密码后才会自动部署。 Tip:每次都得输入密码非常麻烦,我们需要Git免登录

打开Git Bash,

1、在C盘MINGW64 ~$ 模式下,touch创建文件 .git-credentials:

touch .git-credentials

2、用vim编辑此文件,

vim .git-credentials

3、输入内容格式

https://username:password@github.com

4、 最后执行

git config --global credential.helper store

© 2021 欧振江的博客

Powered by Hugo with theme Dream.

avatar

欧振江 的博客与其感慨路难行,不如马上出发。

其他

如果你喜欢我的开源项目或者它们可以给你带来帮助,可以赏一杯咖啡 ☕ 给我。~

If you like my open source projects or they can help you. You can buy me a coffee ☕.~

PayPal

https://cocomede.github.com

Patreon

Become a Patron!

微信赞赏码

wechat

最好附加一下信息或者留言,方便我可以将捐助记录 📝 下来,十分感谢 🙏。

It is better to attach some information or leave a message so that I can record the donation 📝, thank you very much 🙏.

关于我

欧振江 的 ❤️ 博客

记录一些 🌈 生活上,技术上的事

一名大四学生

马上毕业于 🏫 贺州学院学院

职业是前端工程师

业余时间会做开源和

主要的技术栈是:

  • JavaScript & TypeScript
  • HTML/CSS
  • Vue.js
  • Angular

尝试中:

  • Java & Javaweb
  • 微信小程序
  • Android

目前在 暂无工作

下面是我的个人简历

https://www.qmjianli.com/cv/21820WEJ1D57EJBR

– 2021 年 08 月 21 日更新

我的收藏

CSDN