![]()
因为是以前的博客迁移, 这个 hexo 也搭建好多次, 其实每次碰到问题还是挺多的, 这次记录一下吧, 也可能以后还用得着
安装 git 、npm, 不题
安装就开始报错,提示需要权限,加 sudo,挂代理
1 2 3
| sudo npm install hexo-cli -g
# 保证代理可用或者换源
|
初始化,克隆主题失败,还是要挂代理
1 2 3 4
| hexo init
# 保证代理可用或者换源 # 配置环境中如果报出各种莫名其妙的错误, 一般都是 node 版本有问题, homebrew 重装后根据提示操作基本可以解决
|
![]()
![]()
生成SSH公钥
1 2 3 4
| ssh-keygen -t rsa -C "钥匙名"
git config --global user.name “your_username” # 设置用户名 git config --global user.email “your_email” # 设置邮箱
|
想要使用 atom 命令行内打开目录(可选),在 gitbook 搜索到软件自带命令
git 验证, 出现 是直接回车还会输入yes
的问题 ,不忍直视
1 2 3 4 5
| # 不要随便就回车, 有时需要输入 yes 确认的, 回车会报错
ssh -T git@git.coding.net # coding ssh -T git@github.com # github ssh -T git@gitee.com # oschina
|
生成页面,本地测试三连
1 2 3
| hexo clean hexo g hexo s
|
测试成功,准备连接远程仓库,修改_config.yml
1 2 3 4
| deploy: type: git repo: '你的git仓库地址' branch: master
|
提交与部署
1 2
| npm install hexo-deployer-git --save hexo deploy
|
Next 主题
1
| git clone https://github.com/theme-next/hexo-theme-next themes/next
|
绑定域名
因为是以前的博客迁移, 结果在此绑定域名的时候, github 报了一个不常见的错误, 意思是我的域名, 之前有人绑定过了, 不明觉厉
The CNAME *.cc is already taken.
Check out https://help.github.com/articles/troubleshooting-custom-domains/#cname-already-taken for more information.
1 2 3 4 5
| # 解决方法是向 github 提交 support, 大概一个小时, 对方邮件回复, 让我在域名解析中添加一个 TXT 记录
# 解析添加后, 用下面的命令验证一下, 如果生效了就给 github 回复一下邮件, 然后域名就被释放了
dig *.cc(你的域名) TXT
|
![]()
常用插件
1 2 3 4 5 6 7 8 9 10 11
| pjax # 改善页面刷新体验 https://github.com/theme-next/theme-next-pjax
pangu # 自动文字排版 https://github.com/next-theme/hexo-pangu
local_search # 关键字搜索 https://github.com/theme-next/hexo-generator-searchdb
valine # 评论系统 集成无需安装
|
开启分类标签
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| 1, _config.yml 中开启 tags 标签
2, 命令行新建标签页面 hexo new page tags
3, 编辑 _post 中的 tags 页面, 添加 type 字段 title: tags type: "tags"
4, 编辑 _post 中的 tags 页面, 添加下面的字段, 关闭评论 comments: false
# 开启分类页面类似操作
5, 文章置顶 npm uninstall hexo-generator-index --save npm install hexo-generator-index-pin-top --save
# 然后在文章顶部,加入 top: true
6, 百度统计 访问https://tongji.baidu.com注册,获取嵌入码
在博客配置文件中开启 # Baidu Analytics baidu_analytics: 嵌入码
|