干货:从hexo转到hugo写了个python3的脚本: migrate hexo to hugo,毕竟快一年没用Python了,如果有问题欢迎骚扰.
更多参考:https://gohugo.io/hosting-and-deployment/hosting-on-github/
目标
- 不再花钱买VPS了
- 不再依赖太多,安装太多东西在本地,just go env enough!
- 简单快速
部署
推荐部署到 Coding 或者GitHub,Gitee 的自定义域名是要 Pro 会员才可以,花钱的。
关于整个项目的部署我觉得可以这么搞:
以我在 Coding 上为例,其他类似吧,用了 Coding 发现他项目下包含仓库的结构比较舒服。
- 新建项目:hugo
- 进入项目,新建仓库:huifeng.me (私有)
- 还呆在项目里,新建仓库:public(公开)
通过 hugo new site huifeng.me 新建的仓库放的是所有源码了,但是页面皮肤和public文件夹不包含进去。
大概的流程是这样:
hugo new site huifeng.me
git remote add origin <your_repo_url>
git push -u origin master
git submodule add https://github.com/varkai/hugo-theme-zozo themes/zozo
# 上面这样本来是挺好的做法,更新就进去 git pull 就好,可是我还是修改了原有样式,所以有了下面的修改
# 下面两行这样是为了我根据自己想要修改了样式不至于无处保存。
cd ./themes/zozo
git remote set-url origin https://e.coding.net/wedojava/hugo/zozo.git
# 下面的操作是参考的这里:
# https://gohugo.io/hosting-and-deployment/hosting-on-github/#step-by-step-instructions
cd ../../
hugo
cd public
git add .
git commit -m "first public"
git remote add origin https://e.coding.net/wedojava/hugo/public.git
cd ..
echo "public" >> .gitignore
保存下面脚本并修改 +x 权限:
#!/bin/sh
# If a command fails then the deploy stops
set -e
printf "\033[0;32mDeploying updates to GitHub...\033[0m\n"
# Build the project.
hugo # if using a theme, replace with `hugo -t <YOURTHEME>`
# Go To Public folder
cd public
# Add changes to git.
git add .
# Commit changes.
msg="rebuilding site $(date)"
if [ -n "$*" ]; then
msg="$*"
fi
git commit -m "$msg"
# Push source and build repos.
git push origin master
and run: ./deploy.sh "Your optional commit message"
EOF