hexo githubpage 初始化 并解决同步静态页面问题

其实这就是熟悉熟悉怎么用git,不建议一个仓库弄两个分支...

HEXO初始化

暂设当前目录 iamtb,且github仓库A放hexo dynamic文件,仓库B放hexo static文件

npm install -g hexo

npm install hexo-deployer-git --save

hexo init iamtb

在iamtb文件夹下

hexo s

来个NB的NEXT主题

在iamtb目录下载主题NEXT,

git clone https://github.com/iissnan/hexo-theme-next themes/next

修改基本主题配置,包括语言,page等,确保本地预览无误。

[重点来了!!!]

[重点来了!]必须删除下载主题内的.git目录,否则主题无法上传到A库,因为你自己下载的主题文件有.git控制文件夹。
另外一定修改.gitignore ,把其中的node_modulesdb.json,不要ignore,不要ignore,不要ignore。

意思就是你的.ignore文件是这样:

.DS_Store
Thumbs.db
*.log
public/
.deploy*/

推到A仓库

在github新建A仓库,把目前的这些文件都推到A库。参考以下命令

  503  git status
  504  git init
  505  git status
  506  git add *
  507  git commit -m 'init hexo and next theme'
  508  git status
  509  git remote
  510  git remote add origin https://github.com/tuber/tbhexo.git
  511  git branch
  512  git push
  513  git push origin master

建立yourname.github.io

github建立仓库B,建完后可一进入仓库setting进行初始化(Launch automatic page generator),保证访问yourname.github.io正常访问。

本地config配置

目的就是执行hexo d的时候推到B仓库

deploy:
  type: git
  repo: https://github.com/tuber/tuber.github.io.git
  branch: master
  message: just static
 
 

本地发布测试文章

如果网络慢可以在主题设置中禁用google字体

hexo new ‘001’

hexo new ‘002’

hexo new ‘003’

hexo g

git commit -am'add 3 post'

git push origin master #把本地master推到远程origin,此处为A仓库

hexo d #把生成静态文件推到B仓库

完成80%了,如果换电脑了呢?

那我们由于之前都做好了准备,我们只需要在你需要的地方

git clone https://github.com/tuber/tbhexo.git,

这样你目录下就会新增了一个tbhexo文件夹

进入thhexo目录,不用init 不用init 不用init

npm install hexo

npm install hexo-deployer-git

然后还是先hexo s 启动一下,正常没问题

然后从tbhexo文件夹下,(就相当于你另外一台电脑了)
随便创建几个文件:

hexo new add tbhexo 004
hexo new add tbhexo 005
hexo new add tbhexo 006

可以参考以下命令

  504  git status
  505  git add *
  506  git commit -m'add 3 posts and tow helloword posts in tbhexo'
  507  git push origin master

最后一步

hexo d

完工。这样你在另外一台电脑上更新的文章也推到yourname.github.io上了。

如此循环

只需要 git pull origin master更新

git push origin master 上传即可。

大问题:

目测他有一个默认文章hello word ,理论应该在第一个文章,但是经过此番折腾他跑到第三文章了。
贴图:

图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值