GitHub + Hexo 搭建博客总结(一)

安装配置环境

1.安装Node.js,Nodejs官网,更换为淘宝的npm源

1
npm install cnpm -g --registry=https://registry.npm.taobao.org

:cnpm跟npm用法完全一致,只是在执行命令时将npm改为cnpm(以下操作将以cnpm代替npm)

2.安装hexo

1
2
3
4
#安装
sudo npm install hexo-cli -g
#升级
npm update hexo -g

3.初始化Hexo

hexo init

4.安装依赖

npm install
npm install hexo-server --save     #服务器

5.启动Hexo

hexo server

或者简写

hexo clean && hexo g && hexo s

然后浏览器输入 http://localhost:4000 你会看到Hexo的示例页面.

6.配置github,创建代码仓库,这个仓库的名字需要和你的账号对应。格式: yourname.github.io ,然后 https://yourname.github.io ,就是部署的网页地址
Generating a new SSH key
7.config 的一些配置

Plugins:  #插件
- hexo-generator-feed
- hexo-generator-sitemap
#Feed Atom
feed:
    type: atom
    path: atom.xml
    limit: 20

#sitemap
sitemap:
    path: sitemap.xml

theme: jacman #主题更换themes/

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
   type: git
   repo: https://github.com/410900345/410900345.github.io.git #github仓库地址
   branch: master # github分支

格式要比上一行多两个空格,才能正确
8.jacman主题的使用,传送门,在jacman/_config.yml里面设置,评论 comments填写duoshuo_shortname多说的用户名,启用多说评论系统。

使用Hexo

1.新建文章

hexo new "test"

2.生成静态网站

hexo generate

3.hexo部署

hexo deploy     

或者简写

hexo clean && hexo g && hexo d

提示[info] Deploy done: git 说明部署成功,我的个人博客

4.更换主题 jacman

cd  hexo
git clone https://github.com/wuchong/jacman.git themes/jacman

5.sitemap & rss访问/atom.xml和/sitemap.xml

$ npm install hexo-generator-feed --save
$ npm install hexo-generator-sitemap --save
$ npm install hexo-generator-baidu-sitemap --save
$ hexo generate   

必须执行最后一步generate才生效

常见错误

1.白板和Cannot GET / 几个字,我们需要手动配置些东西,我们需要输入下面三行命令:

npm install hexo-renderer-ejs --save
npm install hexo-renderer-stylus --save
npm install hexo-renderer-marked --save
这个时候再重新生成静态文件,命令:
hexo generate (或hexo g)
启动本地服务器:
hexo server (或hexo s)

2.如果在博客文章列表中,不想全文显示,可以增加 , 后面的内容就不会显示

<!--more-->
欣赏此文?求鼓励,求支持!