搭建hexo博客

安装hexo

  1. 安装hexo 首先如果没有安装Node.jsGit, 则要先安装这两个 npm install -g hexo-cli

  2. hexo的更新 npm update -g (好像得重新按照1中的命令重新安装hexo)

创建本地博客

  1. 初始化博客 在你想建立博客的文件夹下执行hexo init

  2. 选择主题 选择自己喜欢的主题, 一般从github上clone到theme文件夹下; 然后根据主题的wiki进行配置

部署到github上

  1. 本地预览 hexo server 在网页http://localhost/4000可以进行本地预览

  2. 部署 配置站点配置文件, 然后hexo generate, hexo deploy

设置next主题本地搜索引擎

  1. 安装searchdb插件 npm install hexo-generator-searchdb --save

设置rss

  1. 安装feed插件 npm install hexo-generator-feed --save
  2. 站点配置文件 加入以下feed配置: > feed: > type: atom > path: atom.xml > limit: 20

  3. 主题配置文件 以next主题为例:

rss: /atom.xml

设置sitemap

  1. 安装sitemap插件 npm install hexo-generator-sitemap --save
  2. 站点配置文件 加入以下sitemap配置:
    1
    2
    plugins:
    - hexo-generator-sitemap
  3. 可以在localhost:4000/sitemap.xml看到网站的sitemap
  4. 然后提交到你网站所用的搜索引擎上, 如swiftype, google, baidu等 >以google为例: (google站点管理) sitemap_google

  5. swiftype设置 swiftype support sitemap.xml 它根据Robots.txt来读取sitemap robotstxt插件的安装与配置

vps上配置hexo博客

  1. 安装nginx yum install nginx

  2. 防火墙允许http/https服务 firewall-cmd --permanent --zone=public --add-service=http firewall-cmd --permanent --zone=public --add-service=https

  3. 设置网站目录 设置location下的root为hexo生成的public文件夹 > 如果出现403forbidden, 可能是权限问题, nginx.conf第一行 > user nobody 改为 user root

  4. 绑定域名 & 设置https server_name 字段改为你的域名

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# included in http brace
# http setting
server {
listen 80;
server_name wengqiang.site;

location / {
root /root/wens07.github.io/public;
index index.html index.htm;
}

// http request turn to htpps
return 301 https://$host$request_uri;

}

# https setting
server {
listen 443 ssl;
server_name wengqiang.site;

ssl_certificate /root/wengqiang.site.cert/Nginx/1_wengqiang.site_bundle.crt;
ssl_certificate_key /root/wengqiang.site.cert/Nginx/2_wengqiang.site.key;

ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;

ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location / {
root /root/wens07.github.io/public;
index index.html index.htm;
}
}

安装waline评论系统

  1. 根据waline官网操作部署好waline服务端(https://vercel.com/wens07)
  2. hexo安装插件支持 sudo npm install @waline/hexo-next
  3. config.yml对waline进行配置
  4. 进入waline的后台管理进行注册,第一个注册即为管理员 https://waline.wengqiang.site/ui/register

设置hexo的页面数学公式渲染

  1. 打开next theme中的math选项
  2. 使用pandoc渲染
    > npm un hexo-renderer-marked
    > npm i hexo-renderer-pandoc
    > if system not install pandoc, you should insall it, apt install pandoc
-------------本文结束感谢您的阅读-------------