hexo-blog-in-Mac

官网 https://hexo.io/zh-cn/docs/

安装 git

安装node.js, brew install node

安装hexo, npm install -g hexo-cli

创建个人博客目录 mkdir MyBlog

hexo init

hexo s, Hexo is running at http://localhost:4000 . Press Ctrl+C to stop. 打开网页,

博客关联到github仓库:配置_config.yml文件。

1
2
3
4
5
6
# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
type: git
repo: https://github.com/UserName/UserName.github.io
branch: master

产生静态网页: hexo g

部署到GitHub page上: hexo d

#出现错误1:

INFO Validating config

ERROR Deployer not found: git

解决办法: npm install --save hexo-deployer-git

#出现错误2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
*** Please tell me who you are.

Run

git config --global user.email "you@example.com"

git config --global user.name "Your Name"

to set your account's default identity.

Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'cbl@bogon.(none)')

error: src refspec HEAD does not match any

error: failed to push some refs to 'https://github.com/CBLkfit/CBLkfit.github.io'

解决办法:设置好git config

  • 图片添加以及上载问题:

    第一步:安装插件

    1
    npm install https://github.com/7ym0n/hexo-asset-image --save

    第二步:打开hexo配置文件_config.yml

    1
    post_asset_folder=true

    第三步:hexo n ‘add_photo’,在source/_posts下生成add_photo.md文件和add_photo文件夹。md文件中添加 ****,就可以在博客中显示图片了。

    注意:需要在菜单栏中选择格式->图像->当插入本地图片时->上传图片