保存文章,发布博客
发布博客更新总结
提交源文件 & 部署站点
在新电脑上修改
hexo搭建博客发布到个人服务器架构流程图
说明:我本人没有使用缓存tmp
保存文章,发布博客
执行清除命令,发布博客,可行。
clean适用于主题样式发生较大改动
1 | 更新文章 |
不执行清除命令,发布博客,可行
1 | 更新文章 |
不执行清除命令,发布博客,不可行
1 | 更新文章 |
发布博客更新总结
与预览
hexo s [-g]无关系git push,发布博客,不可行,
因为仅仅提交更新源码md文件1
2
3git add .
git commit
git push重点说明:仅仅修改文章,不涉及主题修改的,可以不执行clean命令
是否生成html新文件
1
2
3hexo s -g: 否
hexo d -g: 是
hexo g: 是命令 是否生成html新文件 hexo s -g 否 hexo d -g 是 hexo g 是
g/-g参数意义
原来没认真研究横线-意义,总以为都会在本地生成新的html文件
经过多次不同命令发布尝试后,才知道横线-g相当于在内存生成html,所以在发布部署时,必须生成本地的html文件。
1 | s -g是内存生成html,g || d -g是文件生成html,所以在部署时,生成新html上传,使用哪种参数,至关重要! |
提交源文件 & 部署站点
提交源文件(git push): 触发的是master分支(源文件),触发钩子;但博客文件(静态文件public/)未发生上传新文件。
部署站点(hexo deploy): 触发的是blog分支(静态文件),触发钩子;但博客文件(静态文件public/)上传新文件。
操作示例:
1 | ➜ shendawei git:(master) git push |
1 | ➜ shendawei git:(master) ✗ hexo d -g |
总结
1 | 站点博客要更新,只能调用部署的方法。 |
在新电脑上修改
不需要hexo init,不需要git init
编写文章
下载仓库
1
2git clone git@shendawei.cn:/home/git/repos/Doc.git -b master shendawei
cd shendawei初始化submodule next
1
git submodule init
下载submodule next
1
git submodule update
下载npm包
1
2npm install
因为package.json已经配置过hexo&hexo-deploy-git,不用单独install --save.编写文章
1
2hexo new 新文章
编写新文章/修改已有文章预览效果/部署博客
1
2hexo s -g / hexo d -g
修改主题式样时,才需hexo clean提交文章
1
2
3git add .
git commit -s -m "message"
git push
修改主题
cd主题目录(themes/next/)
1
2
3cd themes/next
git submodule update下载的next,分支可能处于游离状态,需先切换到master
git checkout master修改主题文件代码
1
优化主题式样文件
提交主题changes
1
2
3git add .
git commit -s -m "更新主题"
git push返回根目录,提交submodule commit id变化
1
2
3
4
5
6
7
8
9
10
11cd ../..
➜ shendawei git:(master) ✗ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: themes/next
git add .
git commit -s -m "Update submodule: next"
git push