Neil's blog

Let's start from here


  • 首页

  • 归档

  • 标签

  • 关于

Hexo+Github搭建个人博客(4)

发表于 2016-09-24 |

Hexo+Github搭建个人博客遇到的问题

几日不更博,自己的blog就跳出来捣乱了

很开心的写了一篇blog,好的,机械化操作:
hexo g –> hexo d

坐等部署,然后等着我的是

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

    at ChildProcess.<anonymous> (/Users/liushihan/GitHublsh/node_modules/hexo-util/lib/spawn.js:37:17)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:897:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)

什么鬼,感觉受到了伤害,之前明明就是好的。现在hexo不能部署了,sourcetree也不能连接git服务器了,几天不更就坏了?SSH配置了没问题啊~

Calm down!!!

  • 那我看看自己的ssh key

    usr/lsh/.ssh

    打开一看,都在啊(此处有坑)

  • 测测有没有问题

    ssh -T git@github.com

    结果居然连不上了。之前一直这样更新博客的,突然连不上。

  • 查看GitHub ssh配置状态

    也是配好的,和之前一样没动过。

  • 难道是hexo git node 版本要更新?

    好吧,来吧,更新吧 少年~

  • 然并卵

有点生气了,简单粗暴点,删掉之前的ssh key ,重新生成一次

ssh-keygen -t rsa -C “liu601545126@qq.com”

生成成功,会显示文件路径。

  • 换个姿势,再来一次hexo g->hexo d

WTF!

*** 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.

我读书少,你别骗我,git我之前可是配置过的~
算了,再配一次吧~

git config –global user.email “youremail@example.com”

git config –global user.name “yourname”

  • 万事具备,只需deploy

然而,现实又给了我一个响亮的耳光

FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

    at ChildProcess.<anonymous> (/Users/liushihan/GitHublsh/node_modules/hexo-util/lib/spawn.js:37:17)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:897:16)
    at Socket.stream.socket.on (internal/child_process.js:340:11)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at Pipe._handle.close [as _onclose] (net.js:549:12)


Error: EACCES: permission denied, unlink '/Users/liushihan/GitHublsh/.deploy_git/about/index.html'

我不信!!!说我没权限?

show me the code

ssh -T git@github.com
Hi GitHublsh! You've successfully authenticated, but GitHub does not provide shell access.

明明就···明明就···有···

  • 看了下错误,冷静分析一下

应该是这个博客本地库存在未知错误

还是简单粗暴,删掉,重新把git上面的库clone下来,重新生成部署。

To github.com:Githublsh/Githublsh.github.io.git
   0b24cdb..ccae3f1  HEAD -> master
Branch master set up to track remote branch master from git@github.com:Githublsh/Githublsh.github.io.git.
INFO  Deploy done: git

终于成功了···

小结

  1. 回头看看,从一开始的ssh key ,和后来的重新生成的ssh key有点不一样(废话,key是唯一的肯定不一样啊),我说的不是这个,我发现之前的key的文件名自己改了,打开看了一下,好像是SourceTree改的。好吧,当然是原谅它啊~

  2. 到最后发现,是自己的本地库也存在未知错误,果断删掉,重新clone.

  3. 遇到没有头绪的问题,那就从头开始解决。

Hexo+Github搭建个人博客(3)

发表于 2016-09-15 |

博客中添加图片

hexo+github搭建完,开始开开心心的写博客。但是,到了插入图片的时候,好像不是很友好~

尝试一:

本人写博客采用的macdown,首先尝试了本地图片。

在引用图片位置添加:

![“图片名称”](../images/imagename.jpg) 

在日志文件的上级目录,新建文件夹images,用来存放图片。

然后,

hexo g

hexo s

本地查看效果,首页显示正常,进入分类目录,打开后,图片无法显示。

尝试二:

采用七牛云来做图床,亲测可行

步骤:

  1. 七牛云账号注册
  2. 创建对象存储
  3. 创建之后,进行内容管理,上传图片,这个时候会生成外链默认域名
  4. 创建成功,在macdown中添加图片的外链域名(例如:![“请求报文”](http://ot29getcp.bkt.clouddn.com /images/request.png) )

5.添加后本地运行测试,blog 首页展示和分类展示可行

Hexo+Github搭建个人博客(2)

发表于 2016-09-14 |

Hexo+Github搭建个人博客(2)

开始动手配置diy博客


##一、hexo站点配置文件

打开存放整个博客文件下_config.yml:

# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: Neil's blog    #网站标题
subtitle: Let's start from here  #网站副标题
description: 优秀不够,你是否无可替代
author: Neil Liu    #博主的名字
email: codeneil@163.com        #博主的邮箱
language: zh-Hans    #网站使用的语言
timezone:    #网站时区

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

# Directory    目录配置
source_dir: source    #源文件夹,这个文件夹用来存放内容。
public_dir: public    #公共文件夹,这个文件夹用于存放生成的站点文件。
tag_dir: tags    #标签文件夹
archive_dir: archives    #归档文件夹
category_dir: categories    #分类文件夹
code_dir: downloads/code
i18n_dir: :lang    #国际化(i18n)文件夹
skip_render:    #跳过指定文件的渲染,您可使用 glob 表达式来匹配路径。

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post    # 默认布局
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: false    #启动 Asset 文件夹
relative_link: false
future: true
highlight:    #代码块的设置 
  enable: true
  line_number: true
  auto_detect: true
  tab_replace:

# Category & Tag     分类和标签的设置
default_category: uncategorized     #默认分类
category_map:    #分类别名
tag_map:#标签别名

# Archives 默认值为2,这里都修改为1,相应页面就只会列出标题,而非全文
## 2: Enable pagination
## 1: Disable pagination
## 0: Fully Disable
archive: 1
category: 1
tag: 1

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss

# Pagination
## Set per_page to 0 to disable pagination
per_page: 5
pagination_dir: page    #分页目录

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

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repository: git@github.com:Githublsh/Githublsh.github.io.git
  branch: master

二、hexo主题配合文件

打开themes\next下的_config.yml文件

  1. 开启打赏功能

    reward_comment: 让我感受一下知识的力量~
    wechatpay: /images/WechatIMG3.jpeg
    alipay: /images/WechatIMG5.jpeg
    
  2. 开启个人微信二维码

    # Wechat Subscriber
    wechat_subscriber:
      enabled: true
      qcode: /images/WechatIMG7.jpeg
      description: 个人微信,欢迎交流
    
  1. 开启侧边栏社交链接

    social:
      GitHub: https://github.com/your-user-name
      Twitter: https://twitter.com/your-user-name
      微博: http://weibo.com/your-user-name
      豆瓣: http://douban.com/people/your-user-name
      知乎: http://www.zhihu.com/people/your-user-name
      # so on
    
  2. 选择 Scheme

    #scheme: Muse
    scheme: Mist
    #scheme: Pisces
    

更多自定义配置请参考NexT主题配置

Git提交index.lock问题解决

发表于 2016-09-12 |

Git提交或者添加时,提示index.lock文件存在,无法提交或者添加

解决办法一:

  1. On linux/unix/gitbash/cygwin, try:

    rm -f .git/index.lock

  2. On Windows Command Prompt, try:

    de >del .git\index.lock de>

解决办法二:

de >de>

Go to: Tools > Options > Source Control
Select Current source control plug-in as: None

解决办法三:

check if the git still running (ps -ef | grep git)
if not, remove the locked file
if yes, kill the git process at first.

Hexo+Github搭建个人博客(1)

发表于 2016-09-10 |

Hexo+Github搭建个人博客(1)

一、搭建环境

  • Git环境配置
  • node.js环境配置
  • GitHub账号配置

    • 首先,你得有一个Github账号。没有的话,手动再见~
    • 创建一个Repository
      • Repository name填写yourname.github.io,其他的地方看心情填写。
      • 创建之后,开启pages功能,setting–>Github Pages–>Automatic page generator。
      • ok
  • hexo环境搭建

    • npm install -g hexo
    • 安装完成后,自己在本地文件夹新建一个本地blog文件夹(例如:\GitBlog)
    • 命令行进入文件目录,
      • hexo init,然后等新建完成
      • npm install,将在文件中安装node_modeules
      • 安装完成后,hexo g
      • hexo s,[info] Hexo is running at http://localhost:4000/. Press Ctrl+C to stop. 就可以看到本地的blog了

二、基本配置

本地的blog已经可以看到了,接下来就是配置后部署到Github,然后大家都可以看到写的东西了。


  • 回到本地新建的Gitblog文件夹,配置_config.yml文件

    # Deployment
    ## Docs: http://hexo.io/docs/deployment.html
    deploy:
      type:
    

    修改后:

    deploy:
      type: git
      repository: git@github.com:Githublsh/Githublsh.github.io.git
      branch: master
    
repository为Github新建的代码库的地址,如上。
  • 部署到Github上
    • hexo deploy(如果报GitHub权限的问题,配置下SSH即可)
      • ssh-keygen -t rsa -C “your_email@example.com”创建ssh
      • 添加SSH key到GitHub,将公钥拷贝到Github–>Setting–>SSH and GPG keys–>new SSH keys.
    • 部署成功后,打开(我的blog)https://githublsh.github.io/

三、小结

  • 部署步骤

    1. hexo clean
    2. hexo g
    3. hexo d
  • 修改后,本地预览

    1. hexo g
    2. hexo s
    3. 查看页面效果http://localhost:4000
1…121314
Neil Liu

Neil Liu

优秀不够,你是否无可替代

68 日志
25 标签
GitHub
© 2019 Neil Liu
由 Hexo 强力驱动
主题 - NexT.Muse