在github上搭建个人网站

在github上搭建个人网站

标签 : hexo github 个人网站 2017-05


个人网站配置步骤:

  • 安装git node.js(自带npm)
  • 申请github账号,建立仓库(仓库名=用户名.github.io)
  • 本地新建blog文件夹,右键git中安装hexo
    hexo s -g # 本地 localhost:4000 查看网站效果
  • 将blog中的hexo文件提交到github上(需要ssh key)
    hexo d -g # 使用仓库名查看网站效果(用户名.github.io)
  • 在hexo网站寻找不错的主题,添加到本地即可。

PS:建议先把github仓库下到本地,然后在本地仓库中安装hexo等操作.(否则很容易踩git和hexo的坑)
PS:hexo安装中会出现很多迷之报错,原因未知,虽然报错但也可以正常使用。


安装 git node.js npm

安装git
Git官网下载网站:https://git-scm.com/downloads
百度云下载网站:http://pan.baidu.com/s/1dFGeRbr 密码:51zr 版本:Windows-Git-2.13.0-64-bit.exe

安装node.js
  node.js官网下载网站:https://nodejs.org/en/
  百度云下载网站:http://pan.baidu.com/s/1qY8WNZe 密码:ma81 版本:Windows-node-v6.10.3-x64.msi

安装npm
一般而言,安装node.js之后,npm是已经安装好了的。

CMD 查看安装是否成功
git --version
node --version
npm --version

npm commond not found问题 :

建立github仓库

申请github账号,建立仓库,拷贝库到本地

安装hexo

git clone git@github.com:scfan6435/scfan6435.github.io  # 拷贝远程库到本地
  • 进入本地文件夹,右键点击Git Bash Here
  • 安装 hexo
npm install hexo-cli -g # 全局安装hexo
  • 初始化文件夹
hexo init
  • 安装生成器
npm install
  • 安装依赖和插件
hexo s -g # 本地预览hexo页面
  • 浏览器中打开localhost:4000即可查看博客页面。
  • 安装插件,自动将文件push到github
npm install hexo-deployer-git --save

Hexo命令

hexo常用命令

  • 生成新博客
  • hexo new “博客名”

  • generate 生成静态文件

hexo g
  • server启动服务器
hexo s
  • deploy 部署网站。部署网站前,需要预先生成静态文件。
hexo d
  • clean 清除缓存文件 (db.json) 和已生成的静态文件 (public)。
hexo clean
  • 卸载hexo
3.0.0之后版本 npm uninstall hexo-cli -g
3.0.0之前版本 npm uninstall hexo -g
  • 安装指定版本hexo
npm install hexo@2.8.3 -g # 在初始化环境并安装依赖和插件

hexo配置文件:blog/_config.yml文件,主题配置文件:blog/theme/xxx/_config.yml # xxx主题

Hexo额外命令


github仓库链接
域名网站:https://scfan.top/
本地网站:http://localhost:4000/
github网站:https://scfan6435.github.io/

hexo官网主题:https://hexo.io/themes/
个人网站域名设置:http://blog.csdn.net/yanzhenjie1003/article/details/51703370
github搭建网站参考链接:http://blog.csdn.net/a1274624994/article/details/54749094
github搭建网站参考链接:http://www.jianshu.com/p/017e01718d41
hexo博客参照:http://chaoo.oschina.io/
hexo博客参照:https://jysperm.me/


Git常见报错

Git报错:Warning: LF will be replaced by CRLF问题

执行 git init && git add .
报错 warning: LF will be replaced by CRLF
由于Linux和Windows换行符不同的缘故

解决方法:
rm -rf .git
git config --gobal core.autocrlf false  # 这样系统就不会去进行换行符的转换了
重新执行 git init && git add 即可。

[Git报错]:Please make sure you have the correct access rights and the repository exists.

错误原因:由于ssh Key不对,重新生成ssh key,然后贴到github上面去。

配置全局用户名和邮箱

git config --global user.name "yourname"
git config --global user.email“your@email.com"

获取ssh key

ssh-keygen -t rsa -C "your@email.com"  # 获得 ssh_key,将其贴到github上  # 即可成功解决问题

[Git报错]:Git执行push报错error: src refspec master does not match any

由于未提交文件到缓冲池中,git未在缓冲池中找到文件,导致报错。
git add xx
git commit xx
git push xx 即可

[Git报错]:git pull 失败 ,提示:fatal: refusing to merge unrelated histories

在进行Git pull 时,添加一个可选项

git pull origin master --allow-unrelated-histories

参考链接:http://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories


live2d设置

参考网站链接:https://www.moumaobuchiyu.com/2017/04/21/%E5%9C%A8%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E6%90%AD%E5%BB%BAhexo%E5%8D%9A%E5%AE%A2/
教程链接:https://github.com/EYHN/hexo-helper-live2d

本文live2d教程:

加入Q版看板娘

采用的是hexo-helper-live2d插件
来源 : https://github.com/KiritoXF

步骤一 :安装hexo-helper-live2d插件

npm install --save hexo-helper-live2d

步骤二 : 将如下代码加入主题
路径:根目录下的themes/Vateral/layout/index.ejs,加在其后即可

<%- live2d() %>

步骤三 : 配置方法
第一种:在 index.ejs 中添加参数

<%- live2d({
    model: "koharu"
}) %>

第二种:在 根目录 的 _config.yml 中添加参数

live2d:
  model: koharu
  bottom: -60

注: 第二种配置会覆盖第一种
注:配置完成,本地运行 hexo s -g 查看效果
步骤三: 看板娘的属性配置(可选步骤)

model模型属性:live2d官网有
- model 模型名称 默认值: z16
- Gantzert_Felixander
- Epsilon2.1
- haru
- miku
- ni-j
- nico
- nito
- nipsilon
- nietzsche
- shizuku
- tsumiki
- wanko
- z16
- hibiki
- koharu
- haruto
- Unitychan
- tororo
- hijiki
- width 宽度 默认值: 150
- height 高度 默认值: 300
- className 元素的类名 默认值: live2d
- id 元素的id 默认值: live2dcanvas
- bottom 元素的底部偏移 默认值: -20 如果嫌模型位置不正确 可以调整这个参数

推荐使用:koharu

posted @ 2017-05-20 21:16  SuperScfan  阅读(252)  评论(0编辑  收藏  举报