个人博客搭建

个人博客搭建

1.安装node,

方法一:

直接去node官网下载稳定版本即可,

// 检查是否安装成功
$ node -v

方法二:

使用nvm可以安装不同版本的node

先去下载nvm包,windows系统下载nvm-setup.zip安装包,解压nvm-setup.zip安装包,点击exe后缀文件安装,一步步往下安装完,

$ nvm -v // 查看版本

// 使用
$ nvm install 14.16.1  //安装14.16.1版本nodejs
$ nvm  use 14.16.1     //使用14.16.1版本nodejs
$ nvm ls                //查看当前使用的node版本号是14.16.1
$ node -v               //查看node版本号
$ npm -v                //查看npm包版本号

$ nvm uninstall 14.16.1 //卸载不用的nodejs版本

2.使用淘宝镜像,加速下载速度

 $ npm install -g cnpm --registry=https://registry.npm.taobao.org
 
 // 检查是否安装成功
 $ cnpm -v

3.进入到hexo官网,

在终端执行如下操作

$ npm install hexo-cli -g
$ hexo init blog
$ cd blog
$ npm install
$ hexo server

4.在github上创建一个仓库

在这里插入图片描述

5.部署到github

在你blog文件中先安装插件

$ npm install hexo-deployer-git --save

使用编辑器打开blog文件夹,找到_config.yml文件,在最下面找到deploy进行编辑

deploy:
  type: git
  repo: <repository url> # 你创建github仓库是生成的地址,我是用的是ssh下载
  branch: [branch]
  message: [message]

配置完成后在终端执行

$ hexo clean
$ hexo deploy

注意:

在使用hexo deploy时,如果出现了如下报错,可以参考,我使用的是ssh

$ hexo deploy
INFO  Validating config
INFO  Deploying: git
INFO  Clearing .deploy_git folder...
INFO  Copying files from public folder...
INFO  Copying files from extend dirs...
warning: LF will be replaced by CRLF in 2021/09/20/hello-world/index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in archives/2021/09/index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in archives/2021/index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in archives/index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in css/fonts/fontawesome-webfont.svg.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in css/style.css.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in fancybox/jquery.fancybox.min.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in js/jquery-3.4.1.min.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in js/script.js.
The file will have its original line endings in your working directory
On branch master
nothing to commit, working tree clean
fatal: unable to access 'https://github.com/Youngshihao1122/Youngshihao1122.github.io.git/': OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054
FATAL {
  err: Error: Spawn failed
      at ChildProcess.<anonymous> (C:\Users\Lucas Yang\Desktop\blog\node_modules\_hexo-util@2.5.0@hexo-util\lib\spawn.js:51:21)
      at ChildProcess.emit (events.js:314:20)
      at ChildProcess.cp.emit (C:\Users\Lucas Yang\Desktop\blog\node_modules\_cross-spawn@7.0.3@cross-spawn\lib\enoent.js:34:29)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12) {
    code: 128
  }
} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html

则可以先查看git有没有设置name和email

$ git config user.name

$ git config user.email

如果git没有设置,需要先设置

$ git config --global user.name "username"
$ git config --global user.email "email"

我这使用的是ssh下载,所以先生成公钥私钥,如果想知道如何生成ssh,可以参考

$ ssh-keygen -t rsa -C "your_email@example.com"

//等待创建完成后在复制公钥到github上
$ clip < ~/.ssh/id_rsa.pub

6.访问你的博客

https://youngshihao1122.github.io/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值