Github+Hexo搭建个人博客


title: Github+Hexo搭建个人博客
tags: HEXO
category: 个人博客

首发网址:https://tiansztiansz.github.io/2022/01/29/Github+Hexo搭建个人博客/

安装git

https://npm.taobao.org/mirrors/git-for-windows/

往下滑找到最新版本下载安装即可

安装node.js

https://tiansztiansz.github.io/2022/01/27/安装并配置nodejs/

在Github新建仓库

注意仓库名称为用户名.github.io

安装Hexo

在D盘新建blog文件夹,或者其他位置都行

然后打开 git bush 程序,执行以下命令:

cd /d/blog
npm install -g hexo-cli
hexo init
hexo g
hexo s

然后按命令窗口提示打开网页进行预览

将Hexo部署到Github

打开blog文件夹下的_config.yml,将如下内容进行修改。注意在配置文件中,键值对中间一定要加空格,否则会报错

deploy:
  type: git
  repository: 
    github: https://github.com/tiansztiansz/tiansztiansz.github.io.git  #你的仓库地址
    gitee: https://gitee.com/a1866/a1866.git
  branch: master

按如上方法可以实现github和gitee的双部署

然后再在 git bush中输入如下命令:

npm install hexo-deployer-git --save
hexo clean
hexo g
hexo d

以上即可将网站部署到远端,然后打开网址https://tiansztiansz.github.io/,即可看到网站已部署成功,其中tiansztiansz更改为自己的github用户名

更改主题为Next

继续在git bush执行如下命令,下载next主题:

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

打开blog文件夹下的_config.yml,修改主题

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: next

进行本地预览:

hexo s

然后将更改部署到远端:

hexo clean
hexo g
hexo d

常见错误

若出现如下报错,是由于网络原因,再重复执行几次命令就好

fatal: unable to access 'https://github.com/hexojs/hexo-starter.git/': OpenSSL SSL_read: Connection was reset, errno 10054
WARN  git clone failed. Copying data instead
FATAL {
  err: [Error: EPERM: operation not permitted, mkdir 'D:\'] {
    errno: -4048,
    code: 'EPERM',
    syscall: 'mkdir',
    path: 'D:\\'
  }
} Something's wrong. Maybe you can find the solution here: %s http://hexo.io/docs/troubleshooting.html

参考文献

https://www.zhihu.com/column/c_1201860091307458560
https://www.runoob.com/git/git-install-setup.html

本文作者:tiansz

本文链接:https://www.cnblogs.com/tiansz/p/16319571.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   tiansz  阅读(16)  评论(0编辑  收藏  举报
评论
收藏
关注
推荐
深色
回顶
收起
点击右上角即可分享
微信分享提示