Hexo部署到github的疑难杂症,通过hexo d发布到github失败

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hexo部署到github的疑难杂症,通过hexo d发布到github失败相关的知识,希望对你有一定的参考价值。

参考技术A 使用Github部署个人博客已经司空见惯,网上的教程也很多,不过多数都是基于Linux系统的,关于Windows的却比较少。最近自己也尝试在Windows下通过Hexo来做一个博客然后通过 hexo d 来上传到Github,但是却总是提交不成功,经过几次折腾终于找到了解决方案,原来是自己Github的帐号邮箱设置成了 private 导致无法通过 hexo d 上传到Github的。如果有相似情况的小伙伴不妨试试:

在Github 设置(setting)选项找到Emails,然后把 Keep my email addresses private 去掉勾选即可。

具体hexo写博客并发布到Git的教程可以参考 hexo官方文档 或者 小茗同学的博客园

markdown 如何使用Hexo并部署到GitHub页面

## How to use Hexo and deploy to GitHub Pages
* https://github.com/hexojs/hexo
* https://hexo.io/docs/

### 1. Install Hexo
```
$ sudo npm install -g hexo-cli

$ hexo -v
hexo-cli: 0.1.9
os: Darwin 14.3.0 darwin x64
http_parser: 2.3
node: 0.12.7
v8: 3.28.71.19
uv: 1.6.1
zlib: 1.2.8
modules: 14
openssl: 1.0.1p
```

### 2. Create a project for your GitHub Pages
```
$ hexo init yt8yt.github.io
INFO  Copying data to ~/***/yt8yt.github.io
INFO  You are almost done! Don't forget to run 'npm install' before you start blogging with Hexo!

$ cd yt8yt.github.io

$ npm install
```

### 3. Run a test server for your page on Mac
```
$ hexo server
INFO  Hexo is running at http://0.0.0.0:4000/. Press Ctrl+C to stop.
```

### 4. Set information for your new blog
https://hexo.io/docs/configuration.html
```
$ vi _config.yml

~~~~~~~~~~~~~~~~~~ _config.yml ~~~~~~~~~~~~~~~~~~
# Site
title: yt8yt's note
subtitle:
description: yt8yt's personal blog
author: yt8yt
language:
timezone: Japan

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://yt8yt.github.io/
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:
```

### 5. Set information to use Git
https://github.com/hexojs/hexo-deployer-git
```
$ npm install hexo-deployer-git --save
$ vi _config.yml

~~~~~~~~~~~~~~~~~~ _config.yml ~~~~~~~~~~~~~~~~~~
# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
  type: git
  repo: git@github.com:yt8yt/yt8yt.github.io.git
  branch: master
```

### 6. Set "watch" before starting your work
"watch" command can monitor your files.  
https://hexo.io/docs/generating.html
```
$ hexo generate --watch
```

### 7. Create a new post file
```
$ hexo new first-post
INFO  Created: ~/***/yt8yt.github.io/source/_posts/first-post.md
```

### 8. Edit the above file with Markdown or Hexo's Helper
Hexo's Helper  
https://hexo.io/docs/helpers.html  
I use Atom with "shift + control + m" when I use Markdown :-)  
https://atom.io/

### 9. Delete "source/_posts/hello-world.md"
It's not necessary to deploy.

### 10. Deploy your new blog!!
https://hexo.io/docs/deployment.html
```
$ hexo clean
$ hexo deploy
```
After writting the above command, you can see your new blog on GitHub Pages.  
http://******.github.io/

### 11. Change your blog theme
https://github.com/hexojs/hexo/wiki/Themes
```
For instance, How to use the following theme.
https://hexo.io/hexo-theme-light/

## Install it
$ cd yt8yt.github.io
$ git clone git://github.com/tommy351/hexo-theme-light.git themes/light

## Update the above files
$ themes/light
$ git pull

## Set information to use the theme
$ cd yt8yt.github.io
$ vi _config.yml

~~~~~~~~~~~~~~~~~~ _config.yml ~~~~~~~~~~~~~~~~~~
# Extensions
## Plugins: http://hexo.io/plugins/
## Themes: http://hexo.io/themes/
theme: light
```

### 12. Create a new page file
https://hexo.io/docs/writing.html
```
$ hexo new page aboutme
INFO  Created: ~/***/yt8yt.github.io/source/aboutme/index.md

$ cd source/aboutme/

$ vi index.md
```

### 13. Use "Read More"
Write `<!-- more -->` in your articles.  

### 14. Use Plugins
https://github.com/hexojs/hexo/wiki/Plugins

以上是关于Hexo部署到github的疑难杂症,通过hexo d发布到github失败的主要内容,如果未能解决你的问题,请参考以下文章

Hexo部署github博客

用nodejs安装hexo,将hexo部署到github

将hexo博客同时部署发布托管到github和coding

hexo的部署

hexo+github搭建个人博客

搭建Hexo博客并部署到Github