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

阅读目录:

  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

  2. 使配置立即生效

    [root@localhost ~]# source /etc/profile

安装hexo

  1. 创建所需文件夹

    [root@localhost ~]# mkdir /hexo [root@localhost ~]# cd /hexo

  2. 安装

    [root@localhost hexo]# npm install -g hexo

  3. 执行init命令初始化hexo

    [root@localhost hexo]# hexo init

  4. 生成静态页面

    [root@localhost hexo]# hexo generate

  5. 安装git插件

    [root@localhost hexo]# npm install --save hexo-deployer-git

  6. 配置hexo

[root@localhost hexo]# vim _config.yml

# 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 &

  • 登录hexo后台页面
    在浏览器中输入“http://localhost:4000/admin”

  • 产生后台加密后的密码

    [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

  2. 在hexo中实现本地搜索功能

    [root@localhost hexo]# npm install hexo-generator-searchdb --save

  3. 在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"

  • hexo的部署

    hexo deploy

  • 后台启动hexo

    hexo server &

评论

暂无评论