Hexo,其实没有你想象的那么难

阅读目录:html

  1. 安装hexo所需环境nodejs
    • 下载软件
    • 解压
    • 添加环境变量
    • 配置生效
  2. 安装hexo
    • 安装
    • 初始化
    • 生成静态页面
    • 安装Git插件
    • 配置hexo
    • 安装hexo后台
    • 添加RSS,搜索,分享,字数统计插件
    • 关于hexo命令

安装hexo所需环境nodejs

  1. 下载软件(6.14.1)
    官网网址以下:https://nodejs.org/en/download/releases/
[root@localhost ~]# wget https://nodejs.org/download/release/v6.14.1/node-v6.14.1-linux-x64.tar.gz
  • 解压到指定文件夹下
[root@localhost ~]# tar -zxvf node-v6.14.1-linux-x64.tar.gz -C /usr/local/
  1. 添加环境变量
[root@localhost ~]# vim /etc/profile
添加
export NODE_HOME=/usr/local/node-v6.14.1-linux-x64
export PATH=$NODE_HOME/bin:$PATH
  1. 使配置当即生效
[root@localhost ~]# source /etc/profile

安装hexo

  1. 建立所需文件夹
[root@localhost ~]# mkdir /hexo
[root@localhost ~]# cd /hexo
  1. 安装
[root@localhost hexo]# npm install -g hexo
  1. 执行init命令初始化hexo
[root@localhost hexo]# hexo init
  1. 生成静态页面
[root@localhost hexo]# hexo generate
  1. 安装git插件
[root@localhost hexo]# npm install --save hexo-deployer-git
  1. 配置hexo

[root@localhost hexo]# vim _config.ymlnode

# Site
title: louboboooの博客
subtitle: 记录学习的技能和遇到的问题
description: 记录学习的技能和遇到的问题

keywords:
author: loubobooo
language: zh-CN
timezone:

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://loubobooo.com

theme: maupassant

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repo: https://gitee.com/loubobooo/hexo.git
  branch: master
  1. 安装hexo admin后台
  • 安装和启动hexo
[root@localhost hexo]# npm install --save hexo-admin 
[root@localhost hexo]# hexo server -d &
[root@localhost hexo]# node  
> const bcrypt = require('bcrypt-nodejs')   
> bcrypt.hashSync('your password secret here!')   
=> '$2a$10$8f0CO288aEgpb0BQk0mAEOIDwPS.s6nl703xL6PLTVzM.758x8xsi'
  • 修改hexo根目录下的 _config.yml文件:
[root@localhost hexo]# vim _config.yml
  • 在最后增长
admin:
  username: hexo
  password_hash: be121740bf988b2225a313fa1f107ca1
  secret: a secret something
  • username是用户名
  • password_hash是密码的哈希映射值,因为不一样版本的node.js的哈希算法是不同的,全部用上述方法来设置有效的密码哈希值。
  1. 在hexo中实现RRS功能
[root@localhost hexo]# npm install hexo-generator-feed --save
  1. 在hexo中实现本地搜索功能
[root@localhost hexo]# npm install hexo-generator-searchdb --save
  1. 在hexo中实现分享功能
[root@localhost hexo]# npm i -S hexo-helper-qrcode
  1. 在hexo中添加字数统计、阅读时长
[root@localhost hexo]# npm i --save hexo-wordcount
  1. 关于hexo命令
  • 建立通常的文章

    hexo new "文章名称"算法

  • 建立"about"等主题页面
    (其中,"about"要和在主题的_config.yml文件中的menu中进行匹配)

    hexo new page "about"npm

  • hexo的部署

    hexo deployvim

  • 后台启动hexo

    hexo server &浏览器